Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the k-means algorithm to segment the curves directly. You just have to experiment a little with the number of clusters you're gonna use because you have to reserve some clusters for the color of the font, grid, axes and plot backgrounds, and also GUI elements such as these buttons with magnifying glass and hand.

I think 11 clusters should do the trick (1 for each of the 4 curves and 7 for the plot elements listed above). Observe the results and try adding more or remove some of them if you don't get the results you want.

This solution could be fully automated because I presume that all the pictures you are going to analyze would be identical in terms of the interface and only the curves change, so the number of pixels constituting each of the other 7 clusters should be very similar on every picture (number of points constituting the curves would probably also be similar for that matter), so you should be able to identify your curves just by analyzing the number of points belonging to each cluster.

The only problem you may have is when the curves are of the same color as some of the interface elements, e.g. if one of them is of the same color as the font, but it's easy to filter out the unwanted points in such a case, because you may analyze the position of the points belonging to the cluster - if they are near the edges of the image, then it's an interface element.

These links can get you started along with the docs I've linked above:

http://www.pyimagesearch.com/2014/05/26/opencv-python-k-means-color-clustering/

http://www.pyimagesearch.com/2014/07/07/color-quantization-opencv-using-k-means-clustering/

You can use the k-means algorithm to segment the curves directly. You just have to experiment a little with the number of clusters you're gonna use because you have to reserve some clusters for the color of the font, grid, axes and plot backgrounds, and also GUI elements such as these buttons with magnifying glass and hand.

I think 11 clusters should do the trick (1 for each of the 4 curves and 7 for the plot elements listed above). Observe the results and try adding more or remove some of them if you don't get the results you want.

This solution could be fully automated because I presume that all the pictures you are going to analyze would be identical in terms of the interface and only the curves change, so the number of pixels constituting each of the other 7 clusters should be very similar on every picture (number of points constituting the curves would probably also be similar for that matter), so you should be able to identify your curves just by analyzing the number of points belonging to each cluster.

The only problem you may have is when the curves are of the same color as some of the interface elements, e.g. if one of them is of the same color as the font, but it's easy to filter out the unwanted points in such a case, because you may analyze the position of the points belonging to the cluster - if they are near the edges of the image, then it's an interface element.

These links can get you started along with the docs I've linked above:

http://www.pyimagesearch.com/2014/05/26/opencv-python-k-means-color-clustering/

http://www.pyimagesearch.com/2014/07/07/color-quantization-opencv-using-k-means-clustering/

Happy birthday ;)