[Image-SIG] Floodfill

Johan Forsberg johan at slentrian.org
Thu Feb 18 10:23:48 CET 2010


I have been using PIL to write a simple drawing program and it's been great
fun. The only thing I've really been missing from the library is a fast
flood-fill routine. The included python based floodfill, while functional,
is very slow (in 1.1.7), I guess due to the per-pixel access required. Since
I want interactive speed, I decided to try and hack in a floodfill function
in C. Instead of reinventing the wheel, I googled up a nice implementation
in the "graphics gems" collection (
http://tog.acm.org/resources/GraphicsGems/) which needed only small
modifications in order to work with the PIL code. I havent benchmarked it
but it's (not surprisingly) orders of magnitudes faster than the python
routine. I've only implemented it for 8-bit palette image formats since
that's what I use, but it should be easy to generalize.

Would it be a good idea to clean this up and submit it as a patch to PIL?
The graphics gems license is very liberal and seems to me to be compatible
(this is what I found on the webpage above):

The Graphics Gems code is copyright-protected. In other words, you cannot
claim the text of the code as your own and resell it. Using the code is
permitted in any program, product, or library, non-commercial or commercial.
Giving credit is not required, though is a nice gesture.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20100218/88a045b0/attachment.htm>

More information about the Image-SIG mailing list