Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Measure Contrast in OpenCV + Visual C++

The question was previously "How to select image of best contrast in OpenCV" but as per @Rook's suggestion, I'm changing it.

I am going to use OpenCV + Visual Studio 2010 on my project. I just wanna know how OpenCV can make this easier for me. I have extracted around a thousand frames from a video and I need to find out which one has the best contrast. By best, I think the quality between the highest and the lowest contrast.

I have been searching the web for reference codes but so far, I haven't found one.

UPDATE: So basically, I need to measure the contrast and compare values between the images. By the way, this is a video of a Mars Observation via a telescope and I'm gonna be using the frames extracted from it.

like image 898
Masochist Avatar asked Nov 15 '12 12:11

Masochist


People also ask

How do you evaluate the contrast of an image?

Contrast is defined as the difference between the highest and lowest intensity value of the image. So you can easily calculate it from the respective histogram. Example: If you have a plain white image, the lowest and highest value are both 255, thus the contrast is 255-255=0.

How do I adjust contrast on OpenCV?

To increase the contrast levels of the image, simply multiply a constant positive value to each and every image pixel. Similarly if one wishes to decrease the contrast level of the image, then multiply a constant positive value less than 1 for each and every image pixel.

How do you find the contrast of an image in Python?

Just as we saw previously, you can calculate the contrast by calculating the range of the pixel intensities i.e. by subtracting the minimum pixel intensity value from the histogram to the maximum one. You can obtain the maximum pixel intensity of the image by using the np.


1 Answers

Entropy of image is used as a measure of contrast. See this code.

Entropy is a scalar value, statistical measure of randomness that can be used to characterize the texture of the input image. Entropy is defined as

-sum(p.*log2(p))

where p contains the histogram counts.

— Matlab documentation

like image 83
Cfr Avatar answered Sep 22 '22 03:09

Cfr