#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include void help() { printf("\nThis program demonstrated color pyramid segmentation cvcvPyrSegmentation() which is controlled\n" "by two trhesholds which can be manipulated by a trackbar. It can take an image file name or defaults to 'fruits.jpg'\n" "Call:\n" "./pyaramid_segmentation [image_path_filename -- Defaults to fruits.jpg]\n\n" ); } IplImage* image[2] = { 0, 0 }, *image0 = 0, *image1 = 0; CvSize size; int w0, h0,i; int threshold1, threshold2; int l,level = 4; int sthreshold1, sthreshold2; int l_comp; int block_size = 1000; float parameter; double threshold; double rezult, min_rezult; int filter = CV_GAUSSIAN_5x5; CvConnectedComp *cur_comp, min_comp; CvSeq *comp; CvMemStorage *storage; CvPoint pt1, pt2; void ON_SEGMENT(int a) { cvPyrSegmentation(image0, image1, storage, &comp, level, threshold1+1, threshold2+1); /*l_comp = comp->total; i = 0; min_comp.value = cvScalarAll(0); while(i fabs(255- cur_comp->value.val[0]) && fabs(min_comp.value.val[1])> fabs(cur_comp->value.val[1]) && fabs(min_comp.value.val[2])> fabs(cur_comp->value.val[2]) ) min_comp = *cur_comp; i++; }*/ cvShowImage("Segmentation", image1); } int main( int argc, char** argv ) { char* filename = argc == 2 ? argv[1] : (char*)"fruits.jpg"; if( (image[0] = cvLoadImage( filename, 1)) == 0 ) return -1; cvNamedWindow("Source", 0); cvShowImage("Source", image[0]); cvNamedWindow("Segmentation", 0); storage = cvCreateMemStorage ( block_size ); image[0]->width &= -(1<height &= -(1<