2

I want to determine image sharpness by the amount of high frequencies within the image. As far as I understand the dft() function from OpenCV returns two matrices with real and complex numbers. This is where I am stuck. How can I determine the amount of high frequencies from this data?

I am thankful for every hint/link which could provide me with a better understanding.

Greetings

dcfyg
  • 75
  • 9
  • Do you want to see this in a magnitude image, or work with the values in further processing? – Øystein W. Jan 25 '16 at 11:24
  • Sorry I am not sure if I understand your question correctly. The idea was to be able to say that image 1 is sharper than image 2 or vice versa. So I need to compute a value which represents the sharpness of the image. – dcfyg Jan 25 '16 at 11:34
  • 1
    This might help? http://answers.opencv.org/question/5395/how-to-calculate-blurriness-and-sharpness-of-a-given-image/ – Øystein W. Jan 25 '16 at 12:18
  • Or I would convolve the image with a laplacian kernel and then sum up the value. – Øystein W. Jan 25 '16 at 12:20
  • Thanks for the suggestions, I've have already implemented some other ways of measuring sharpness. I want to compare them, so I am especially looking for a way to do it with the DFT. – dcfyg Jan 25 '16 at 13:32
  • Then I would suggest a magnitude image and evaluate the center area. There are a lot of guides out there – Øystein W. Jan 25 '16 at 14:07
  • The values in the two matrices correspond to the amplitude and phase shift of a wave. The frequency is determined by the coordinates in the matrices. The position of the high frequencies depends on how your Fourier transformation was implemented. It is common to center the output of the DFT so that the lowest frequencies are near the center of the matrices and the highest in the corners (I think this is the way opencv does it). – Gilfoyle Jan 25 '16 at 15:39
  • I've read something similar, but how do I determine the total amout of high frequencies. – dcfyg Jan 25 '16 at 16:21

1 Answers1

1

Make FT
Calculate magnitude of result

Now you have 2D matrix. Consider upper left quadrant (other are mirrors for real source).
Here Magn[0][0] entry corresponds to zero frequency, and Magn[(n-1)/2][(n-1)/2] entry corresponds to the highest frequency.
Left upper part of this submatrix contains low-frequency samples, so you can calculate sum of values in this part and in the rest part and compare these sums. For example (pseudocode):

cvIntegral(Magn, Rect(0..n/4, 0..n/4)) compare with 
cvIntegral(Magn, Rect(0..n/2, 0..n/2)) - cvIntegral(Magn, Rect(0..n/4, 0..n/4))
MBo
  • 77,366
  • 5
  • 53
  • 86