-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.5.c.cpp
More file actions
45 lines (29 loc) · 1.25 KB
/
5.5.c.cpp
File metadata and controls
45 lines (29 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Part5.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//
#include <iostream>
#include <cxcore.h>
#include <cv.h>
#include <_highgui.h>
int main()
{
//##################################################################################
// упражнение 5.5
IplImage* src1 = cvLoadImage("../Part3/picture/88.png");
IplImage* src2 = cvLoadImage("../Part3/picture/88.png");
IplImage* src1_gray = cvCreateImage(cvGetSize(src1), IPL_DEPTH_8U, 1);
IplImage* src2_gray = cvCreateImage(cvGetSize(src2), IPL_DEPTH_8U, 1);
cvCvtColor(src1, src1_gray, CV_BGR2GRAY);
cvCvtColor(src2, src2_gray, CV_BGR2GRAY);
IplImage* diff = cvCreateImage(cvGetSize(src1), IPL_DEPTH_8U, 1);
cvAbsDiff(src1_gray, src2_gray, diff);
IplImage* thresh = cvCreateImage(cvGetSize(src1), IPL_DEPTH_8U, 1);
cvThreshold(diff, thresh, 128, 255, CV_THRESH_BINARY);
// упражнение 5.5.c
IplImage* mop = cvCreateImage(cvGetSize(src1), IPL_DEPTH_8U, 1);
cvThreshold(thresh, mop, 128, 255, CV_MOP_OPEN);
cvNamedWindow("Square", CV_WINDOW_AUTOSIZE);
cvShowImage("Square", diff);
cvWaitKey(0);
cvDestroyWindow("Square");
getchar();
}