[BangPypers] Convert to Black and White to an image

Narendra Sisodiya narendra at narendrasisodiya.com
Sat Jan 8 06:04:49 CET 2011

On Sat, Jan 8, 2011 at 10:22 AM, Venkatraman S <venkat83 at gmail.com> wrote:

> On Sat, Jan 8, 2011 at 10:19 AM, Narendra Sisodiya <
> narendra at narendrasisodiya.com> wrote:
> >
> > I am sorry but your code snippet was less efficient then what i posted
> > initially. moreover, I was having black and white image.
> >
> I thought you needed BW image. (I should read properly!!)
> Also, can you expatiate on how it was less efficient - i would love to
> learn.

Yes, I need black and white image, and I was having a grayscale image, I
have posted initially this thing.
you posted a RBG to black and white algorithm - even if somebody has RBG ,
why one should use at RBG level, the right way is to do is to convert to
grayscale using avalable method.
Also, you are using
n = image.getpixel((i,j))
if n[0] < 127: #R value

Which is totally wrong, you are using usiing R value, Any image which has
lower R value or just haivng B and G component will be converted into fully
black image. you should average or just L = xR+yB+zG method to get a average
grayscale value of that pixel. {mainly intensity}
Also, I too wrote pixel by pixel method which is expensive and I wanted to
know better predefined algorithm. which i got.
point method

│    Narendra Sisodiya
│    http://narendrasisodiya.com

More information about the BangPypers mailing list