OpenCV学习:cvPyrSegmentation金字塔分割算法

学习金字塔分割算法:需要建立一个CvMemStorage* storage = cvCreateMemStorage(0)
#include"cv.h"
#include"highgui.h"

int main()
{
	IplImage* src=cvLoadImage("D:/1.jpg",1);
	//图像大小必须能被2^level整除
	IplImage* resize=cvCreateImage(cvSize(512,512),8,3);
	IplImage* dst=cvCreateImage(cvSize(512,512),8,3);
	cvResize(src,resize);

	CvMemStorage* storage = cvCreateMemStorage(0);
	CvSeq* comp = NULL;
	cvPyrSegmentation(resize,dst,storage,&comp,6,200,50);
	cvReleaseMemStorage(&storage);
    cvNamedWindow( "show", 1 );      
	// Show the image in the named window       
	cvShowImage( "show", dst );  
	// Press any key to exit.   
	cvWaitKey(0);      
	// Clean up and don’t be piggies   
    cvDestroyWindow( "show");  
	cvReleaseImage( &src );  
    cvReleaseImage( &dst );  
	return 0;  

}

OpenCV学习:cvPyrSegmentation金字塔分割算法_第1张图片

 

http://blog.csdn.net/gnuhpc/article/details/4284463还是这位大牛写得比较好

你可能感兴趣的:(OpenCV学习:cvPyrSegmentation金字塔分割算法)