Detect which image is sharper

后端 未结 5 1470
情话喂你
情话喂你 2020-12-07 18:56

I\'m looking for a way to detect which of two (similar) images is sharper.

I\'m thinking this could be using some measure of overall sharpness and generating a score

5条回答
  •  天涯浪人
    2020-12-07 19:43

    The simple method is to measure contrast -- the image with the largest differences between pixel values is the sharpest. You can, for example, compute the variance (or standard deviation) of the pixel values, and whichever produces the larger number wins. That looks for maximum overall contrast, which may not be what you want though -- in particular, it will tend to favor pictures with maximum depth of field.

    Depending on what you want, you may prefer to use something like an FFT, to see which displays the highest frequency content. This allows you to favor a picture that's extremely sharp in some parts (but less so in others) over one that has more depth of field, so more of the image is reasonably sharp, but the maximum sharpness is lower (which is common, due to diffraction with smaller apertures).

提交回复
热议问题