1 IPLIMAGE image[2], image0, image1;
\r
5 int threshold1, threshold2;
\r
7 int sthreshold1, sthreshold2;
\r
9 int block_size = 1000;
\r
12 double rezult, min_rezult;
\r
13 CvFilter filter = CV_GAUSSIAN_5x5;
\r
14 CvConnectedComp *cur_comp, min_comp;
\r
16 CvMemStorage *storage;
\r
20 void ON_SEGMENT(int a)
\r
23 cvPyrSegmentation(image0, image1, storage, &comp,
\r
24 level, threshold1, threshold2);
\r
26 l_comp = comp->total;
\r
28 printf(" l_comp = %d \n ",l_comp);
\r
33 cur_comp = (CvConnectedComp*)cvGetSeqElem ( comp, i, 0);
\r
34 if(fabs(CV_RGB(255,0,0)- min_comp.value)>
\r
35 fabs(CV_RGB(255,0,0)- cur_comp->value))
\r
36 min_comp = *cur_comp;
\r
38 pt1.x = cur_comp->rect.x;
\r
39 pt2.x = cur_comp->rect.x + cur_comp->rect.width;
\r
40 pt1.y = cur_comp->rect.y;
\r
41 pt2.y = cur_comp->rect.y + cur_comp->rect.height;
\r
42 cvRectangle(image1, pt1, pt2, 255, 3);
\r
47 pt1.x = min_comp.rect.x;
\r
48 pt2.x = min_comp.rect.x + min_comp.rect.width;
\r
49 pt1.y = min_comp.rect.y;
\r
50 pt2.y = min_comp.rect.y + min_comp.rect.height;
\r
51 cvRectangle(image1, pt1, pt2, 255, 3);
\r
53 // bitmap1 = get_image_cv(image1);
\r
54 show_iplimage("Segmentation", image1);
\r
59 image[0] = load_iplimage("..\\Bitmaps\\parrot.bmp");
\r
61 named_window("Source", 0);
\r
62 show_iplimage("Source", image[0]);
\r
65 printf("\n i = %d width = %d height = %d", i,size.width, size.height);
\r
68 named_window("Segmentation", 0);
\r
71 storage = cvCreateMemStorage ( block_size );
\r
73 image0 = cvCreateImage(cvSize(image[0]->width, image[0]->height), IPL_DEPTH_8U, 3);
\r
74 image1 = cvCreateImage(cvSize(image[0]->width, image[0]->height), IPL_DEPTH_8U, 3);
\r
75 cvCopy(image[0],image0,0);
\r
78 // segmentation of the color image
\r
87 sthreshold1 = create_slider("Threshold1", "Segmentation", &threshold1, 255, ON_SEGMENT);
\r
88 sthreshold2 = create_slider("Threshold2", "Segmentation", &threshold2, 255, ON_SEGMENT);
\r
90 show_iplimage("Segmentation", image1);
\r
93 destroy_window("Segmentation");
\r
94 destroy_window("Source");
\r
96 cvReleaseMemStorage (&storage );
\r
99 cvReleaseImage (&image[0]);
\r
100 cvReleaseImage (&image0);
\r
101 cvReleaseImage (&image1);
\r