+++ /dev/null
-IPLIMAGE image[2], image0, image1;\r
-CvSize size;\r
-\r
-int w0, h0,i;\r
-int threshold1, threshold2;\r
-int l,level;\r
-int sthreshold1, sthreshold2;\r
-int l_comp;\r
-int block_size = 1000;\r
-float parameter;\r
-double threshold;\r
-double rezult, min_rezult;\r
-CvFilter filter = CV_GAUSSIAN_5x5;\r
-CvConnectedComp *cur_comp, min_comp;\r
-CvSeq *comp;\r
-CvMemStorage *storage;\r
-\r
-CvPoint pt1, pt2;\r
-\r
-void ON_SEGMENT(int a)\r
-{ \r
- \r
- cvPyrSegmentation(image0, image1, storage, &comp, \r
- level, threshold1, threshold2);\r
-\r
- l_comp = comp->total;\r
-\r
- printf(" l_comp = %d \n ",l_comp);\r
- i = 0;\r
- min_comp.value = 0;\r
- while(i<l_comp)\r
- {\r
- cur_comp = (CvConnectedComp*)cvGetSeqElem ( comp, i, 0);\r
- if(fabs(CV_RGB(255,0,0)- min_comp.value)>\r
- fabs(CV_RGB(255,0,0)- cur_comp->value))\r
- min_comp = *cur_comp;\r
-/* \r
- pt1.x = cur_comp->rect.x;\r
- pt2.x = cur_comp->rect.x + cur_comp->rect.width;\r
- pt1.y = cur_comp->rect.y;\r
- pt2.y = cur_comp->rect.y + cur_comp->rect.height;\r
- cvRectangle(image1, pt1, pt2, 255, 3);\r
-*/ \r
- i++;\r
- }\r
-/* \r
- pt1.x = min_comp.rect.x;\r
- pt2.x = min_comp.rect.x + min_comp.rect.width;\r
- pt1.y = min_comp.rect.y;\r
- pt2.y = min_comp.rect.y + min_comp.rect.height;\r
- cvRectangle(image1, pt1, pt2, 255, 3);\r
-*/ \r
-// bitmap1 = get_image_cv(image1);\r
- show_iplimage("Segmentation", image1);\r
-\r
-\r
-};\r
-\r
-image[0] = load_iplimage("..\\Bitmaps\\parrot.bmp");\r
-\r
-named_window("Source", 0);\r
-show_iplimage("Source", image[0]);\r
-wait_key(0);\r
-\r
-printf("\n i = %d width = %d height = %d", i,size.width, size.height); \r
-\r
-\r
-named_window("Segmentation", 0);\r
-\r
-\r
-storage = cvCreateMemStorage ( block_size );\r
-\r
-image0 = cvCreateImage(cvSize(image[0]->width, image[0]->height), IPL_DEPTH_8U, 3);\r
-image1 = cvCreateImage(cvSize(image[0]->width, image[0]->height), IPL_DEPTH_8U, 3);\r
-cvCopy(image[0],image0,0); \r
-image0->roi = NULL;\r
-image1->roi = NULL;\r
-// segmentation of the color image\r
-l = 1;\r
-level =4;\r
-threshold1 =255;\r
-threshold2 =30;\r
-\r
-\r
-ON_SEGMENT(1);\r
-\r
-sthreshold1 = create_slider("Threshold1", "Segmentation", &threshold1, 255, ON_SEGMENT);\r
-sthreshold2 = create_slider("Threshold2", "Segmentation", &threshold2, 255, ON_SEGMENT);\r
-\r
-show_iplimage("Segmentation", image1);\r
-wait_key(0);\r
-\r
-destroy_window("Segmentation");\r
-destroy_window("Source");\r
-\r
-cvReleaseMemStorage (&storage );\r
-\r
-\r
-cvReleaseImage (&image[0]);\r
-cvReleaseImage (&image0);\r
-cvReleaseImage (&image1);\r
-\r