16 lines
721 B
Plaintext
16 lines
721 B
Plaintext
Many image processing algorithms are defined for [[wp:Grayscale|grayscale]] (or else monochromatic) images.
|
|
|
|
|
|
;Task:
|
|
Extend the data storage type defined [[Basic_bitmap_storage|on this page]] to support grayscale images.
|
|
|
|
Define two operations, one to convert a color image to a grayscale image and one for the backward conversion.
|
|
|
|
To get luminance of a color use the formula recommended by [http://www.cie.co.at/index_ie.html CIE]:
|
|
|
|
<big> L = 0.2126 × R + 0.7152 × G + 0.0722 × B </big>
|
|
|
|
When using floating-point arithmetic make sure that rounding errors would not cause run-time problems or else distorted results when calculated luminance is stored as an unsigned integer.
|
|
<br><br>
|
|
|