Something like gimp "fuzzy select" in python / PIL

I have an image with some object on a non-solid background. I want to extract these objects like in gimp using "fuzzy selection". This could be an example:

http://img249.imageshack.us/gal.php?g=25750902.png

The question is the best way to do it with python / PIL ...

+2


a source to share


2 answers


My guess is that you need some kind of flood algorithm (like width traversal) where you stop examining pixels with a different color than black.

Wikipedia has a great explanation with animation and pseudocode



http://en.wikipedia.org/wiki/Flood_fill

+2


a source


Also, if you want to add a "tolerance" feature to Photoshop, you must apply this Connected-component_labeling method when connecting to a vertex on your graphic while filling a fill.



0


a source







All Articles