opencv练习:将两幅同样大小的图像想减并显示结果

 

(2011-08-10 14:51:05)
转载▼
标签:

杂谈

 

关键函数cvAbsDiff()

,代码如下:

#include "cv.h"
#include "highgui.h"
#include "cxcore.h"

int main(int argc,char** argv)
{cvNamedWindow("a",0);
IplImage* img=cvLoadImage("11.jpg");
cvShowImage("a",img);

cvNamedWindow("b",0);
IplImage* img1=cvLoadImage("12.jpg");
cvShowImage("b",img1);

IplImage* diff=cvCreateImage(cvGetSize(img),img->depth,img->nChannels);
cvAbsDiff(img,img1,diff);
cvNamedWindow("r",0);
cvShowImage("r",diff);

while (1)
{if (cvWaitKey(100)==27) break;
}

cvDestroyWindow("a");
cvDestroyWindow("b");
cvReleaseImage(&img);
cvReleaseImage(&img1);
cvReleaseImage(&diff);
return 0;
}
运行结果见下图:

opencv练习:将两幅同样大小的图像想减并显示结果_第1张图片

opencv练习:将两幅同样大小的图像想减并显示结果_第2张图片

opencv练习:将两幅同样大小的图像想减并显示结果_第3张图片

你可能感兴趣的:(opencv练习:将两幅同样大小的图像想减并显示结果)