核心函数:cvCanny
程序:
代码:
#include "cv.h" #include "cxcore.h" #include "highgui.h" #include <iostream> int canny(int argc,char** argv) { IplImage* src1=cvLoadImage("e:\\picture\\7.jpg",0); //源图像和目的图像都必须为灰度图像 IplImage* src2=cvLoadImage("e:\\picture\\8.jpg",0); IplImage* src3=cvLoadImage("e:\\picture\\4.jpg",0); IplImage* dst1=cvCreateImage(cvGetSize(src1),8,1); IplImage* dst2=cvCreateImage(cvGetSize(src2),8,1); IplImage* dst3=cvCreateImage(cvGetSize(src3),8,1); cvCanny(src1,dst1,50,125); //第三个和第四个参数分别为上下阀值,建议上下阀值的比为2:1到3:1 cvCanny(src2,dst2,50,125); cvCanny(src3,dst3,50,125); cvNamedWindow("src1"); cvNamedWindow("src2"); cvNamedWindow("src3"); cvNamedWindow("dst1"); cvNamedWindow("dst2"); cvNamedWindow("dst3"); cvShowImage("src1",src1); cvShowImage("src2",src2); cvShowImage("src3",src3); cvShowImage("dst1",dst1); cvShowImage("dst2",dst2); cvShowImage("dst3",dst3); cvWaitKey(0); cvDestroyWindow("src1"); cvDestroyWindow("src2"); cvDestroyWindow("src3"); cvDestroyWindow("dst1"); cvDestroyWindow("dst2"); cvDestroyWindow("dst3"); cvReleaseImage(&src1); cvReleaseImage(&src2); cvReleaseImage(&src3); cvReleaseImage(&dst1); cvReleaseImage(&dst2); cvReleaseImage(&dst3); return 0; }
本文出自 “flyclc” 博客,请务必保留此出处http://flyclc.blog.51cto.com/1385758/1539739
原文地址:http://flyclc.blog.51cto.com/1385758/1539739