How To Flood-fill Part Of A Bitmap Enclosed By A Black Border With My Chosen Color?
I want to programmatically modify a bitmap using python but don't really need a thorough grounding in the subject, so would like to concentrate on learning just what I need to get
Solution 1:
PIL has an undocumented function ImageDraw.floodfill
:
>>>import ImageDraw>>>help(ImageDraw.floodfill)
Help on function floodfill in module ImageDraw:
floodfill(image, xy, value, border=None)
Fill bounded region.
(Flood-filling should generally be a last resort because it interacts poorly with anti-aliased lines. It is usually better to get the actual boundary data for the counties and then draw a filled polygon. However, PIL doesn't support anti-aliased line drawing so this advice is useless unless you switch your drawing module to something more capable like PythonMagick or pycairo.)
Solution 2:
You can try the opencv binding in python. Here is some example: http://opencv.willowgarage.com/documentation/python-introduction.html
You can then use the cvFloodFill
function to flood fill a region.
Post a Comment for "How To Flood-fill Part Of A Bitmap Enclosed By A Black Border With My Chosen Color?"