[BangPypers] Convert to Black and White to an image

kunal kunal.t2 at gmail.com
Fri Jan 7 17:57:36 CET 2011

On 01/07/2011 10:04 PM, Narendra Sisodiya wrote:
> Can somebody give an easy way to convert a image into black and white using
> a given threshold..
> Currently I am doing like this
>      image=ImageOps.grayscale(image)
>      for i in range(0,width):
>          for j in range(0,height):
>              if image.getpixel((i,j))<= 200:
>                  image.putpixel((i,j),0)

another way to grayscale an image is:

from PIL import Image
a = Image.open("image_0065.jpg")#color image
b= a.convert("L")

b is a grayscale image now ;)

> What is the general mailing list to ask question on python ?

The Image SIG mailing list would be a more appropriate place
image-sig at python.org

Kunal Ghosh
Dept of Computer Sc.&  Engineering.

permalink: member.acm.org/~kunal.t2

More information about the BangPypers mailing list