Click here to Skip to main content
15,917,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a two bmp files of the same scene and I would like determine if one is more bright than the other. Similarly I have a set of bmps with different contrasts and another set of bmps with different saturation. How do I compare these images for brightness,contrast and saturation ? These test images are saved by a tool provided by the sensor manufacturer. I am using gcc 4.5.
Posted

The term "brightness" is a very unlucky term as it is often used incorrectly, especially in computer-related color space issues, mostly due to poor understanding of physics by the people who introduced the terms. Please see:
http://en.wikipedia.org/wiki/Brightness[^].

I would prefer to call it "value", as in the name of the color space "HSV". Please see:
http://en.wikipedia.org/wiki/HSV_color_space[^].
This article explains some controversies in "brightness" or "lightness".

For more general understanding of color spaces, please see:
http://en.wikipedia.org/wiki/Color_space[^].

[EDIT]

Please also see my notes to Solution 1.

—SA
 
Share this answer
 
v2
Your question is interesting, but hard to answer in short. First of all I would recommend you get some image library on board that allows you to access each pixel of your images without writing tons of code to read the bmp files.

Then you want to take a close look at your images. Are they precisely registered, i.e. taken from the exact same point with the exact same camera viewing direction and the same focal length? In that case you can compare pixels from one image directly with pixels from the other image. If not you will first have to align the images.

You might want to think about what exactly "brighter" means. Brighter in parts of the image, brighter in average, brighter in a particular area of the image?

In the simplest case, you just calculate the average pixel brightness of image 1 and compare that with the average pixel brightness in image 2. If the brightness difference resulted from different lighting or different exposure settings, that is probably a valid method.

Similar things apply to contrast and saturation. For contrast you might want to calculate the standard deviation of pixel brightness values. For saturation you might go by the average saturation of all image pixels.

Hope that gives you a rough road map for your task.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 28-Jun-12 14:34pm    
There are some good points in this answer, but in fact the problem is even more complex. (I voted 4.)
The problem is that there are no unambiguous way to determine the "brightness" or "lightness" even if you define it. It also depends on some assumption on the used color space, which is some element of arbitrary decision. This is not just a historical or technological casus, but has its roots in relative, ambiguous and individual nature of color perception in human (and other animals). In a way, the subjective brightness depends on the individual; and there are different approaches to work around this problem or provide some uniform criteria.

I provided just the references for some basic reading in my answer, please see.
--SA
nv3 28-Jun-12 14:43pm    
Your points are all valid, Sergey. In this case I think Johnny is still at a beginners level in image processing. In that stage it is permissible to think of the value in a gray scale image as brightness. More important it seemed to me to get his awareness about images to have variations in exposure across the image area and hence, while one spot is brighter, another may be darker than the reference image.

Color metrics, understanding color spaces etc. are the high art of the trade. And as you said, these form an entire branch of science.
Sergey Alexandrovich Kryukov 29-Jun-12 18:13pm    
Well, I agree with you. As to the "high art", the following is important: to be aware that such issues exist, at least to understand that things are not so trivial or not as simple as they may seem, to be aware of terminology and hence to know where to find information when those issues become critical. Agree?
--SA
nv3 30-Jun-12 3:03am    
Absolutely, Sergey.
Sergey Alexandrovich Kryukov 30-Jun-12 14:05pm    
Great. Thank you for the interesting discussion.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900