#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
IplImage* deCanny(IplImage* in, double lowThresh, double highThresh, double aperture)
{
if(in->nChannels != 3)
{
return(0);
}
IplImage* out = cvCreateImage( //为out边缘图像申请空间
cvSize(cvGetSize(in).width,cvGetSize(in).height),
IPL_DEPTH_8U,
1
);
cvNamedWindow("out");//创建窗口
cvCanny(in, out, lowThresh, highThresh, aperture);//in边缘检测
return(out);
}
IplImage* dopyDown(IplImage* in,int filter = IPL_GAUSSIAN_5x5)
{
assert(in->width%2 == 0 && in->height%2 == 0);
IplImage* out = cvCreateImage( //为out申请空间,为1/4大小
cvSize(in->width/2,in->height/2),
in->depth,
in->nChannels
);
cvPyrDown(in,out);//将in按比例缩小复制给out
return(out);
}
void example2_4(IplImage* image)
{
cvNamedWindow("in");
cvShowImage("in",image);
/*IplImage* out = cvCreateImage(
cvGetSize(image),
IPL_DEPTH_8U,
3
);*/
IplImage* out = deCanny(image,50,150,3);
//IplImage* out = dopyDown(image,IPL_GAUSSIAN_5x5);
//out = dopyDown(out,IPL_GAUSSIAN_5x5);
// cvSmooth(image,out,CV_GAUSSIAN,3,3);//平滑处理,图像会变模糊
cvShowImage("out",out);
cvReleaseImage(&out);
cvWaitKey(0);
cvDestroyWindow("in");
cvDestroyWindow("out");
}
int _tmain(int argc, _TCHAR* argv[])
{
IplImage* img = cvLoadImage("拍照时间-02-06-09.bmp");
example2_4(img);
return 0;
}
opencv对图片的处理
最新推荐文章于 2024-10-26 11:50:41 发布