[Image-SIG] Removing specific range of colors from scanned image

Eduardo Ismael eismb at hotmail.com
Sat Apr 25 07:14:49 CEST 2009


I scanned a color page from a book and I would like to remove specific colors from it. The page was scanned at 300dpi.
Suppose I wanted to remove the blue color of the image; because the quality of the color is not even, I had the blue color in different levels, apparently from (185, 208, 231) to (207, 240, 255) - I used "Little RGB Color Picker" to find that out. I tried the following:

im = Image.open("C:\Scan_119.jpg")
pixels = im.load()
width, height = im.size

for x in range(width):
        for y in range(height):
            if pixels[x, y] >= (185, 208, 231):
                if pixels[x, y] <= (207, 240, 255):
                    pixels[x, y] = (255, 255, 255)

But it had little success removing the blue color - I suppose due to the complexity of stablishing a range between two tuples of 3 values. How can I efficiently set a color range to be found or removed with PIL? Is there an algorithm to find such range?



Faça já uma busa e ganhe um wink do Messenger. Está esperando o que? É grátis!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090425/7241ecab/attachment.htm>

More information about the Image-SIG mailing list