As part of a homework assignment, we are implementing the Inverse Filter. Degrade an image then recover with an Inverse Filter.
I convolve the image in the spatial domain with a 5x5 box filter. I FFT the filter, FFT the degraded image, then divide the degraded image by the filter. Inverse FFT the result into an image and I get garbage.
If I FFT the image, FFT the filter, multiply the two, divide that result by the FFT'd filter, obviously I get very close to the original image. ((X*Y)/Y ~== X)
I have an inkling the math is not as simple as "spatially convolved == FFT multiplication".
What is is the correct way to use the Inverse Filter? I have the exact kernel used degrade the image. I'm not adding any noise.
Bovik's textbook, The Essential Guide to Image Processing is almost completely dismissive of the Inverse Filter. Gonzalez&Woods is a bit more hopeful but almost immediately skips to the Wiener Filter.
I have a similar question on stackoverflow.com https://stackoverflow.com/questions/7930803/inverse-filter-of-spatially-convolved-versus-frequency-convolved-image
(This questions should also be tagged [homework] but the tag doesn't exist yet and I haven't the rep to create it.)
EDIT. For some of the great suggestions below. @dipan-mehta Before I FFT, I am padding the convolution kernel to the same size as the image. I'm putting the kernel into the upper left. I ifft(ifftshift()) then save to an image and I get a good result. I've done the ifft(ifftshift()) on both the kernel and the image. Good(ish) results. (Images are in my https://stackoverflow.com/questions/7930803/inverse-filter-of-spatially-convolved-versus-frequency-convolved-image question.)
@jason-r is probably correct. I don't understand the mathematics of the underlying convolution + transform. "Deconvolution" was a new word for me. Still have much to learn. Thanks for the help!
My solution for the homework assignment is to do everything in the frequency domain. I spoke with the professor. I was making the assignment harder than necessary. She wanted us to add noise then try the Inverse Filter, Wiener Filter, and Constrained Least Squares Filter. The point of the exercise was to see how the filters handled noise.