Image segmentation (colors?) With opencv C ++

http://i.imgur.com/iIv4gJa.png

As the graph showed, I would like to enter an image and get several segments as a result.

This is exactly the same as the cluster of the nearest color segment, so I think that it is close to the concept of โ€œcontributingโ€?

I searched for relevant questions here, but still don't know how to start and build a structure in opencv C ++. I am looking for some advice, and I will be very grateful that you will receive the implementation code for me! Thanks for any help!

====================================================

Edit 5/19/2015

Let me add that one of my implementation attempts is Watershed here :( http://blog.csdn.net/fdl19881/article/details/6749976 ).

enter image description here

This is not perfect, but I want the result. In this tool, the user must work manually (draw the watershed lines), so I'm looking for an AUTOMATIC version. It sounds a little complicated, but ... I will be grateful for some suggestion or piece of code to do this.

+5
source share
2 answers

Opencv Documentation: Link

Options: here

Sample code for filtering Meanshift:

#include "opencv2/core/core.hpp" #include "opencv2/imgproc/imgproc.hpp" using namespace cv; using namespace std; Mat img, res, element; int main(int argc, char** argv) { namedWindow( "Meanshift", 0 ); img = imread( argv[1] ); // GaussianBlur(img, img, Size(5,5), 2, 2); pyrMeanShiftFiltering( img, res, 20, 45, 3); imwrite("meanshift.png", res); imshow( "Meanshift", res ); waitKey(); return 0; } 

This is the result with your image, you may need pre-processing before or maybe find some better parameters:

output

EDIT: output with some Gaussian blur in advance (comment in code)

here

+2
source

The problem with considering existing segmentation approaches is that they are either implemented in Matlab (which no one can use Uni), or they are not automatic. The approach when a user must pre-process an image by selecting objects of interest or levels that indicate how to separate colors is not useful because it is not automatic. If you like, you can try my OpenCV-based segmentation implementation described in this post. This is not ideal, but it is automatic and does most of the work, and you can really download the source and try it.

+1
source

All Articles