On Thu, May 28, 2009 at 10:53 PM, Peter Yen <[email protected]> wrote: > Hi Fredrik, > > Thanks for your quick response. The background is unknown at the time of > processing. Actually I don't need a very accurate methodology to remove all > background, removing partially is good enough. > > imagick has method like floodfill, curious how to do that with PIL.
There's a floodfill function in ImageDraw that might be good enough for you. I'm not sure it's documented, but here's the PythonDoc markup: ## # (experimental) Fills a bounded region with a given color. # # @def floodfill(image, xy, value, border=None) # @param image Target image. # @param xy Seed position (a 2-item coordinate tuple). # @param value Fill color. # @param border Optional border value. If given, the region consists of # pixels with a color different from the border color. If not given, # the region consists of pixels having the same color as the seed # pixel. It's pure Python, so if you want more complex rules for determining what's background and not, you can always grab a copy and tweak the code. </F> _______________________________________________ Image-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/image-sig
