[BangPypers] Convert to Black and White to an image

Narendra Sisodiya narendra at narendrasisodiya.com
Fri Jan 7 18:01:59 CET 2011


On Fri, Jan 7, 2011 at 10:27 PM, kunal <kunal.t2 at gmail.com> wrote:

> 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 ;)
>
>
Thanks, but i was aware for this, Still my query is unsolved..



>
>
>
>> 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
>
>
> --
> regards
> -------
> Kunal Ghosh
> Dept of Computer Sc.&  Engineering.
> Sir MVIT
> Bangalore,India
>
> permalink: member.acm.org/~kunal.t2 <http://member.acm.org/%7Ekunal.t2>
> Blog:kunalghosh.wordpress.com
> Website:www.kunalghosh.net46.net
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
┌─────────────────────────┐
│    Narendra Sisodiya
│    http://narendrasisodiya.com
└─────────────────────────┘


More information about the BangPypers mailing list