#!python # -*- mode: python; Encoding: utf-8; coding: utf-8 -*- # Last updated: <2016/11/26 10:01:13 +0900> u""" PIL(Pillow)のfloodfillを試す. PIL(Pillow)には、文書化されていないが floodfill という関数があって、 塗りつぶし処理ができるらしい。 動作確認環境 : Windows10 x64 + Python 2.7.12 + Pillow 3.4.2 """ from PIL import Image from PIL import ImageDraw import time im = Image.open("./tmp_image.png") start = time.time() ImageDraw.floodfill(im, (64, 64), (255, 0, 0, 255), border=None) ImageDraw.floodfill(im, (200, 240), (0, 255, 0, 255), border=None) ImageDraw.floodfill(im, (480, 400), (0, 0, 255, 255), border=None) etime = time.time() - start print("%f" % etime) im.save("./tmp_image_result.png")