16 bit to mono!
Hi
is tehre an algo to convert 16 bit color images to mono ?? (vairous shades of grey) or at least anyone knows how to do it ??
thkns
It's good to be an outcast, you don't need to explain what you do, you just do it and say you don't belong there.
For each pixel, just take your red, green and blue values and average them together. Set this average value as your new red, green and blue for that pixel.
Average is not the right way. To do it perfectly, you should notice that humans eye sees green brighter than red and blue. You should multiply red, green and blue channels with certain values before you take the average, but I can''t remember what they are =(
-Hans
-Hans
Akura, "shades of gray" is called greyscale. Mono means "one" so a monochrome image can only have 2 colors (a 1bit palette of 2 colors, usually black and white).
Just clearing up the terms you''re using
Like Hans said, you should weigh green more than red and blue. But the difference between "average" and "weighted average" is very small, so for speed purposes you might want to just do the average.
byte greyscale_pixel = (_16bitpixel >> 10) + ((_16bitpixel & 0x07f0) >> 4) + ((_16bitpixel & 0x001f) << 1);
This is assuming a 565 RGB pixel. It weighs green twice as much as red and blue.
The way it works is to scale green down to 0-127, red from 0-63 and blue from 0-63. The resulting value is therefore in the range 0-253, close enough to white.
Hope this helps
Just clearing up the terms you''re using

Like Hans said, you should weigh green more than red and blue. But the difference between "average" and "weighted average" is very small, so for speed purposes you might want to just do the average.
byte greyscale_pixel = (_16bitpixel >> 10) + ((_16bitpixel & 0x07f0) >> 4) + ((_16bitpixel & 0x001f) << 1);
This is assuming a 565 RGB pixel. It weighs green twice as much as red and blue.
The way it works is to scale green down to 0-127, red from 0-63 and blue from 0-63. The resulting value is therefore in the range 0-253, close enough to white.
Hope this helps
Just a little side note, for completeness. Do not confuse RGB-blended colours with the true sensitivity of the human eye. It is true, yes, that the human eye is more sensitive to "green" light. But it is only slighlty so. If I recall, about 20% of "green" light incident on the eye is actually absorbed by the cone cells, while 19% of "red" wavelength light is absorbed. This is in severe contrast to light in the "blue" part of the spectrum, wavelengths which are only absorbed up to an amount of about 1.5%. What this means, in fact, is that the human eye is much less sensitive to "blue" light...although that''s not to say that the human brain doesn''t know how to make up for it. The RGB colour scheme is a great approximation of this process...although there are colours which cannot be created by mixing these three primary colours.
------When thirsty for life, drink whisky. When thirsty for water, add ice.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement