#include "stdafx.h"
#include "highgui.h"
#include "cv.h"
/*
%%此部分是原书上的canny边缘检测函数。。。有问题啊,输出全灰的图像
IplImage* doCanny(
IplImage* in,
double lowThresh,
double highThresh,
double aperture)
{
if(in->nChannels != 1)
return(0);
IplImage* out = cvCreateImage(cvSize(in->width, in->height),IPL_DEPTH_8U,1);
cvCanny(in, out, lowThresh, highThresh, aperture);
return(out);
}
*/
/*以下调用cvCanny的自带函数
canny算子有两个阈值,上限和下限,构造函数定义为:
void cvCanny(const CvArr* img,CvArr* edges,double lowthreshold,double highthreshold,int apertureSize=3);
*/
void ShowTwoImg(IplImage* image1, IplImage* image2)
{
cvNamedWindow("Picture_in", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Picture_out", CV_WINDOW_AUTOSIZE);
cvShowImage("Picture_in", image1);
cvShowImage("Picture_out", image2);
cvReleaseImage( &image1);
cvReleaseImage( &image2);
cvWaitKey(0);
cvDestroyWindow("Picture_in");
cvDestroyWindow("Picture_out");
}
int _tmain(int argc, _TCHAR* argv[])
{
IplImage* img1 = cvLoadImage("gray.jpg");
//千万别忘了下面这句啊,要不dstimg的大小特性什么的cvCanny怎么猜得到?!
IplImage* dstimg = cvCreateImage(cvSize(img1->width,img1->height),8,1);
cvCanny(img1, dstimg, 10,100,3);
ShowTwoImg(img1, dstimg);
return 0;
}
#include "highgui.h"
#include "cv.h"
/*
%%此部分是原书上的canny边缘检测函数。。。有问题啊,输出全灰的图像
IplImage* doCanny(
IplImage* in,
double lowThresh,
double highThresh,
double aperture)
{
if(in->nChannels != 1)
return(0);
IplImage* out = cvCreateImage(cvSize(in->width, in->height),IPL_DEPTH_8U,1);
cvCanny(in, out, lowThresh, highThresh, aperture);
return(out);
}
*/
/*以下调用cvCanny的自带函数
canny算子有两个阈值,上限和下限,构造函数定义为:
void cvCanny(const CvArr* img,CvArr* edges,double lowthreshold,double highthreshold,int apertureSize=3);
*/
void ShowTwoImg(IplImage* image1, IplImage* image2)
{
cvNamedWindow("Picture_in", CV_WINDOW_AUTOSIZE);
cvNamedWindow("Picture_out", CV_WINDOW_AUTOSIZE);
cvShowImage("Picture_in", image1);
cvShowImage("Picture_out", image2);
cvReleaseImage( &image1);
cvReleaseImage( &image2);
cvWaitKey(0);
cvDestroyWindow("Picture_in");
cvDestroyWindow("Picture_out");
}
int _tmain(int argc, _TCHAR* argv[])
{
IplImage* img1 = cvLoadImage("gray.jpg");
//千万别忘了下面这句啊,要不dstimg的大小特性什么的cvCanny怎么猜得到?!
IplImage* dstimg = cvCreateImage(cvSize(img1->width,img1->height),8,1);
cvCanny(img1, dstimg, 10,100,3);
ShowTwoImg(img1, dstimg);
return 0;
}