开发者

something like gimp "fuzzy select" in python/PIL

I have image with some object at not solid ba开发者_如何学Cckground. I want to extract this objects like in gimp using "fuzzy select". This can be an example:

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

Question is what is the best way to do it using python/PIL...


I suppose you would need some flood-fill algorithm (such as breadth-first-traversal) in which you stop exploring pixels with different color than black.

Wikipedia has an excellent explanation with animations and pseudo-code

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


And besides, if you want to add feature like "tolerance" in Photoshop, you should apply this method Connected-component_labeling when getting connected vertex on your graph while doing flood fill


As of today, skimage 0.19 has a flood fill algorithm: link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜