图像帧间差分
2019-07-13 12:08发布
生成海报
图像帧间差分
图像帧间差分代码:
#include"cv.h"
#include"highgui.h"
#include"math.h"
#include"cxcore.h"
int main()
{
int i,j;
IplImage* image1=0;
IplImage* gg=0;
IplImage* image2=0;
image1=cvLoadImage("E:\图片\背景建模\000.jpg", 0);
image2=cvLoadImage("E:\图片\背景建模\002.jpg", 0);
gg=cvCreateImage( cvSize(image1->width,image1->height), 8, 1 );
for(i=0;iwidth;i++)
{
for(j=0;jheight;j++)
{
CvPoint pt = {i,j};
((uchar*)(gg->imageData + gg->widthStep*pt.y))[pt.x]=abs(
((uchar*)(image1->imageData + image1->widthStep*pt.y))[pt.x]-
((uchar*)(image2->imageData + image2->widthStep*pt.y))[pt.x]);
}
}
cvNamedWindow( "image1", 1);
cvNamedWindow( "image2", 1);
cvNamedWindow( "gg", 1);
cvShowImage("image1",image1);
cvShowImage("image2",image2);
cvShowImage("gg",gg);
cvWaitKey(0);//等待按键
//销毁窗口
cvDestroyWindow("image1");
cvDestroyWindow("image2");
cvDestroyWindow("gg");
//释放图像
cvReleaseImage(&image1);
cvReleaseImage(&image2);
cvReleaseImage(&gg);
return(0);
}
运行结果:
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮