-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplayImage.cpp
More file actions
69 lines (51 loc) · 1.52 KB
/
Copy pathdisplayImage.cpp
File metadata and controls
69 lines (51 loc) · 1.52 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*******************************************************************
This is a simple MEX file. It just calls openCV functions for loading,
smothing and diaplaying the results
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
#include "mex.h"
int smoothImage(char* filename){
//load the image
IplImage* img = cvLoadImage(filename);
if(!img){
printf("Cannot load image file: %s\n",filename);
return -1;
}
//create another image
IplImage* img_smooth = cvCloneImage(img);
//smooth the image img and save the result to img_smooth
cvSmooth(img, img_smooth, CV_GAUSSIAN, 5, 5);
// create windows to show images
cvNamedWindow("Original Image", CV_WINDOW_AUTOSIZE);
cvMoveWindow("Original Image", 100, 100);
cvNamedWindow("Smoothed Image", CV_WINDOW_AUTOSIZE);
cvMoveWindow("Smoothed Image", 400, 400);
// show the images
cvShowImage("Original Image", img );
cvShowImage("Smoothed Image", img_smooth );
// wait for a key
cvWaitKey(0);
//destroy windows
cvDestroyWindow("Original Image");
cvDestroyWindow("Smoothed Image");
//release images
cvReleaseImage(& img);
cvReleaseImage(& img_smooth);
return 0;
};
void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
if (nrhs != 0)
{
mexErrMsgTxt("Do not give input arguments.");
}
if (nlhs != 0)
{
mexErrMsgTxt("Do not give output arguments.");
}
char *name = "cameraman.png";
smoothImage(name);
}