This repository has been archived by the owner on Aug 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsmoothimage.cc
64 lines (38 loc) · 1.57 KB
/
smoothimage.cc
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Example : smooth an image
// usage: prog <image_name>
// Author : Toby Breckon, toby.breckon@cranfield.ac.uk
// Copyright (c) 2006 School of Engineering, Cranfield University
// License : LGPL - http://www.gnu.org/licenses/lgpl.html
#include "cv.h" // open cv general include file
#include "highgui.h" // open cv GUI include file
int main( int argc, char** argv )
{
IplImage* inputImg = NULL; // input image object
IplImage* outputImg = NULL; // output image object
char const * windowName = "OPENCV: blurred image"; // window name
// check that command line arguments are provided and image reads in OK
if( argc == 2 && (inputImg = cvLoadImage( argv[1], 1)) != 0 )
{
// Create the output image (same size & depth as input)
outputImg = cvCreateImage(cvSize(inputImg->width,inputImg->height),
inputImg->depth, inputImg->nChannels);
// blur the input image using a 5 x 5 mask and store in output image
cvSmooth(inputImg, outputImg, CV_BLUR, 5, 5, 0, 0);
// create window object
cvNamedWindow(windowName, 1 );
// display image in window
cvShowImage( windowName, outputImg);
// start event processing loop (very important,in fact essential for GUI)
cvWaitKey(0);
// destroy window object
// (triggered by event loop *only* window is closed)
cvDestroyWindow( windowName );
// destroy image object
cvReleaseImage( &inputImg );
cvReleaseImage( &outputImg );
// all OK : main returns 0
return 0;
}
// not OK : main returns -1
return -1;
}