Masochist
Masochist

Reputation: 399

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.

Upvotes: 9

Views: 8324

Answers (1)

Cfr
Cfr

Reputation: 5133

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

Upvotes: 4

Related Questions