核心函数:cvLaplace
相当于x方向的二阶导数加上y方向的二阶导数
程序:
代码:
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
int laplace(int argc,char** argv)
{
IplImage* src1=cvLoadImage("e:\\picture\\7.jpg",0);
IplImage* src2=cvLoadImage("e:\\picture\\8.jpg",0);
IplImage* dst1=cvCreateImage(cvGetSize(src1),IPL_DEPTH_16S,src1->nChannels); //注意类型是IPL_DEPTH_16S
IplImage* dst2=cvCreateImage(cvGetSize(src2),IPL_DEPTH_16S,src1->nChannels);
IplImage* result1=cvCreateImage(cvGetSize(src2),8,src1->nChannels);
IplImage* result2=cvCreateImage(cvGetSize(src2),8,src1->nChannels);
cvZero(dst1);
cvZero(dst2);
cvZero(result1);
cvZero(result2);
cvLaplace(src1,dst1); //相当于x方向的二阶导数加上y方向的二阶导数
cvLaplace(src2,dst2);
cvConvertScale(dst1,result1);
cvConvertScale(dst2,result2);
cvNamedWindow("src1");
cvNamedWindow("src2");
cvNamedWindow("dst1");
cvNamedWindow("dst2");
cvShowImage("src1",src1);
cvShowImage("src2",src2);
cvShowImage("dst1",result1);
cvShowImage("dst2",result2);
cvWaitKey(0);
cvDestroyWindow("src1");
cvDestroyWindow("src2");
cvDestroyWindow("dst1");
cvDestroyWindow("dst2");
cvReleaseImage(&src1);
cvReleaseImage(&src2);
cvReleaseImage(&dst1);
cvReleaseImage(&dst2);
cvReleaseImage(&result1);
cvReleaseImage(&result2);
return 0;
}
转载于:https://blog.51cto.com/flyclc/1539842