8

For a project, I want to measure the contrast of a global image.

I want to compare different images to get the image with the best contrast. I know about the Weber contrast, but I need a normalized contrast value (in the range between 0-1 or other).

Is there a simple method to do this in openCV?

jonsca
  • 1,994
  • 3
  • 21
  • 39
  • 2
    Can you clarify what you mean by a "global" image? – jonsca Sep 06 '12 at 01:07
  • 1
  • I was thinking about a simple method, but this can be tricky. So far I have seen computing contrast by response of Laplace operator or DoG (Difference of Gaussian), but this will give you result for single scale only. Depends on how elaborate your measurements should be, you may consider building Laplacian pyramid and then summing up absolute responses in each level of the pyramid. The result can be normalized with respect to maximum possible response (e.g. measure for checkerboard pattern). – Libor Sep 06 '12 at 18:12
  • 1
    mhnm i thought laplace is to calculate the sharpness. – 501 - not implemented Sep 06 '12 at 19:07
  • 1
    I have seen using Laplace in context of "local contrast". There are many definitions. It depends greatly on your application. For example, you can measure just color contrast of every pixel (distance from gray) or you can measure differences in neighboring pixels, or get some measurement from histogram, or take contrast as difference between darkest and lightest point in the image. – Libor Sep 06 '12 at 20:39
  • 2
    Standard deviation of pixel values is a good metric. – Andrey Rubshtein Oct 30 '12 at 16:20
  • @Andrey yes :) in time i use this feature and it works quite good :) – 501 - not implemented Oct 30 '12 at 19:01

2 Answers2

7

One simple way for quantification of contract that I can think of is through use of image histogram. Following is my suggestion

  1. Compute Histogram of the Image
  2. From the counts compute entropy

If you just want to try it out you can use the matlab inbuilt function http://www.mathworks.ch/ch/help/images/ref/entropy.html

You can use the entropy value of the histogram as a measure of contract.

mkuse
  • 395
  • 1
  • 2
  • 10
3

A simple way to calculate contrast is by computing the standard deviation of the greyed image pixel intensities.