opencv 图像尺度空间介绍

测试图片:

opencv 图像尺度空间介绍_第1张图片

code:

#include <opencv\cv.h>
#include <opencv\highgui.h>
#include <opencv\cxcore.h>
#include <stdio.h>


#define SCALESIZE 20
int main(int argc, char* argv[])
{
	IplImage* src;

	src = cvLoadImage("C:\\Users\\zxl\\Desktop\\test1.jpg",0);

	int winSize[SCALESIZE],i;
	IplImage* scaleImage[SCALESIZE];
	IplImage* edgeImage[SCALESIZE];

	char filename[256];

	winSize[0] = 3;
	scaleImage[0]=cvCreateImage(cvGetSize(src),8,1);
	edgeImage[0]=cvCreateImage(cvGetSize(src),8,1);
	
	for( i=1;i<SCALESIZE;i++)
	{
		winSize[i] = winSize[i-1]+2;
		scaleImage[i]=cvCreateImage(cvGetSize(src),8,1);
		edgeImage[i]=cvCreateImage(cvGetSize(src),8,1);
	}

	
	for(i=0;i<SCALESIZE;i++)
	{
		cvSmooth(src,scaleImage[i],CV_GAUSSIAN,winSize[i],winSize[i]);

		cvCanny(scaleImage[i], edgeImage[i], 30, 90, 3);
	}

	//保存图像
	for(i=0;i<SCALESIZE;i++)
	{
		sprintf(filename,"scale_%d.jpg",i);

		cvSaveImage(filename,scaleImage[i]);

		sprintf(filename,"edge_%d.jpg",i);

		cvSaveImage(filename,edgeImage[i]);


	}

	for(i=0;i<SCALESIZE;i++)
	{
		cvReleaseImage(&scaleImage[i]);
		cvReleaseImage(&edgeImage[i]);
	}
	cvReleaseImage(&src);
	return 0;
}


 

 

你可能感兴趣的:(opencv 图像尺度空间介绍)