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;
IplImage* image = cvLoadImage("31.jpg",CV_LOAD_IMAGE_COLOR);
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;
int spatial_radius = 40;
int color_radius = 40;
filtered->width &= -(1<<level);
filtered->height &= -(1<<level);
cvPyrMeanShiftFiltering(filtered, filtered,spatial_radius,color_radius,level);
cvNamedWindow( "fourth", 1 );
cvShowImage( "fourth", filtered);
cvWaitKey(0);
return 0;
}
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
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 ?
inRange() might be useful ( maybe needs conversion to hsv before)