For obvious reasons this conversion method is called the arithmetic mean method. There is also a geometric mean method (it basically sucks and uses (R*G*B)^1/3 - so if R,G, or B are 0 you get black).

Proportional sum of the colors.

This algorithm is simple but the basis of it is much more complex. The formula looks like:

Y = .30 * R + .59 * G + .11 * B.

The percentages here relate to how perceptive the eye is to a given color.

"The formula used in the GIMP is Y = 0.3R + 0.59G + 0.11B; this result is known as luminance. The weights used to compute luminance are related to the monitor's phosphors. The explanation for these weights is due to the fact that for equal amounts of color the eye is most sensitive to green, then red, and then blue. This means that for equal amounts of green and blue light the green will, nevertheless, seem much brighter. Thus, the image obtained by the normal averaging of an image's three color components produces a grayscale brightness that is not perceptually equivalent to the brightness of the original color image. The weighted sum that defines Y, however, does." - READ FULL TEXT, SEE PRETTY EXAMPLE PICTURES at http://gimp-savvy.com/BOOK/index.html?node54.html

cheers

tachyon


In reply to Re: convert image to greyscale (color to black and white) by tachyon
in thread convert image to greyscale (color to black and white) by PodMaster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.