4
$\begingroup$

I am trying to learn about inverse filtering of images and am trying it out on a test image in MATLAB.

The test image is an 8x8 checkerboard, with 64x64 pixels, generated by the MATLAB code:

g = checkerboard(8);

I am using a 3x3 averaging filter, h, and convolving it with the test image.

I am not adding noise and I want to see the results of direct inverse filtering the distorted image.

I am applying the deconvolution function in the frequency domain by:

1) Padding the 3x3 averaging mask h to generate a 64x64 mask hp.

2) Centering the coefficients (0.111...) of hp to maintain symmetry.

3) Multiplying hp by (-1)^x+y (since I want the fft of the mask to give me a centered Fourier transform, hpc.

4) Taking the FFt of the padded, centered mask and multiplying (-1)^(u+v) (since I centered the mask in the spatial domain in step 2) to give me H.

5) Taking the distorted, and frequency shifted test image and dividing it by H, (ie. Y = G./H). (Note: I am not padding the image since the mask was padded, and wraparound is not a huge concern here)

6) Obtaining the inverse filtered image inv = (-1)^x+y * real(ifft2(Y))

My question: Why can't I obtain the original (or something very close to it)?

$\endgroup$
1
$\begingroup$

I think I found out the answer to my own question.

Since I'm using an averaging filter mask (some constant multiplied by a matrix of ones), the Fourier Transform of such a filter is an impulse at zero frequency.

When I pad the mask filter in step 1 to make the dimensions of the mask equal to the image, I am 'truncating' the filter, ie. windowing the mask, which is akin to multiplying the Fourier Transform of the mask with a sinc function.

As a result, the Frequency Domain filter I use in step 5, ie. H, is not an impulse but a sinc function. That's the reason why my results are not ideal.

On the other hand, if I were to use an impulse in step 5, only the zero-frequency value would remain, and my result would be a constant image.

In short, it's a lose-lose situation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.