something like gimp “fuzzy select” in python/PIL

2019-07-21 00:44发布

I have image with some object at not solid background. 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...

2条回答
三岁会撩人
2楼-- · 2019-07-21 00:47

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

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-07-21 00:51

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

查看更多
登录 后发表回答