Question

I need to automate the analyses of many similar images which are basic lots of small blackish blobs on a somewhat homogeneous brown background.

I have tried the find_blobs method from simpleCV but it is not accurate enough. However with gimps contiguous selection tool, also known as Magic wand, I was able to achieve much better results, in separating the background from my blobs.

My problem is that I need to automate this process, so I can't have a person clicking on each image. Any suggestion of a Python friendly library in which I can find this functionality? Is using Gimp in batch mode the only way?

Was it helpful?

Solution

pdb.gimp_image_select_contiguous_color is the programatic way - in a Python plug-in - of doing the magic wand. The drawback is that you have to issue suitable starting coordinates for it to work well. Maye repeating the process in 3 distant points of the image, and if the selection does not diverge by much in two of those, assume that to be the one you want.

The procedure does not return the selection drawable, so you have to get it by issuing pdb.gimp_image_get_selection afterwards. You will also need to set the threshold by calling pdb.gimp_context_set_sample_threshold before calling it.

(My suggestion: copy it to another, new image, resize that to an 8x8pixel image, from which you can get the pixel values and compare directly against other selections made);

OTHER TIPS

OpenCV could be the answer, this brief tutorial may help you. In that example it uses "blur" to make the image more homogeneous, if it is not enough you could try also with erode and dilate.

Those examples are in C++, but opencv python bindings are really similar to C++ interface, so you should not have any problem translating it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top