# How to find a segment location after applying PyrMeanShiftFiltering.

I am using following code to differentiate between a sky blue region (required region) in my image

and the background. I have applied PyrMeanShiftFiltering function to do segmentation of the image. After applying code the result

image have successfully segmented sky blue section but now i want to know the location of this sky blue region (mid point). Can any one help me how i can know the coordinates of this blue region in my image after doing this image segmentation.

#include "cv.h"
#include "highgui.h"
#include "math.h"
#include <iostream.h>

int main(int argc, char** argv)
{
IplImage* output_image;

CvMemStorage* storage = cvCreateMemStorage(0);
cvNamedWindow( "origional image", 1 );
cvShowImage( "origional image", image);
cvWaitKey(0);

IplImage *filtered = cvCreateImage(cvGetSize(image),image->depth,image->nChannels);

cvCopy(image,filtered,NULL);

int level = 3;

filtered->width &= -(1<<level);
filtered->height &= -(1<<level);

cvNamedWindow( "fourth", 1 );
cvShowImage( "fourth", filtered);
cvWaitKey(0);

return 0;
}

edit retag close merge delete

hello, noob, --

problem #1 is, that you're trying to use the deprecated c-api. opencv moved away from that in 2010 already, and most of it is no more maintained.

before trying to improve anything here, - please try to rewrite it, using c++, cv::Mat and cv::pyrMeanShiftFiltering

( 2016-11-12 03:51:24 -0500 )edit

Actually, i am working on a project that is totally based on visual c++ 6.0 and opencv 1.0. I cannot change version because project is very complex and i would need to make complete new project if i will change version. I have googled my query but all help is related to new versions. Please help me is there any way i can achieve my goal while using these versions ?

( 2016-11-12 03:58:04 -0500 )edit

inRange() might be useful ( maybe needs conversion to hsv before)

( 2016-11-13 03:41:13 -0500 )edit