how to identify whether the image is Black and white or the color image?
I am 开发者_开发技巧working on a sample which loads a bitmap image and display it on to window. I want to identify whether the image is Black and white image or the color image.
Please let me know how to identify it. I want win32/MFC sample.
Regards
Step 1: Loop over all pixels or over the palette in an indexed image, and check if the R, G, B values are identical (or very close). If they are, it's a greyvalue image.
Step 2: Create a histogram. If it's a black and white image, it should have a two sharp peaks. You can measure that e.g. by finding a suitable binary threshold (Min+Max/2, Otsu, etc.) and calculating the standard deviation for each of the two halves of the histogram.
精彩评论