Fourier Filtering using CIMg & C++

1k views Asked by At

I need to implement a very simple filter that suppresses a range of frequencies. Then I need to compute the inverse Fourier transform and save the new image.

I am using the CImg library ( C++ ). So far I have done:

const CImg<unsigned char> img(source_img);
CImgList<> F = img.get_FFT();

and I am stuck here. F is a a list of two CImg objects the real and Imaginary part , correct?

Having this F how I suppress frequencies and reconstruct the new Image?

P.S. This is a homework, so I don't want a solution but an explanation of what to do, how to do it and why.

1

There are 1 answers

1
MSalters On BEST ANSWER

Since it's homework, do feel free to experiment.

The first step you need to get working is to directly transform the image back, and get the original input. If this doesn't work, you'd be quite happy to catch it early.

The second step is to just zero some part of the FFT, transform the result back, and see how it differs. Each pixel in the FFT represents a frequency in the input, so experiment to find the relation. Then explain that relation to yourself.

Finally, once you have figured out which are of pixels you want to zero and which ones to keep, create a black& white mask, turn that into a greyscale image, and then blur it. A sharp edge in the FFT domain has an infinite support in the image domain - in practice, that causes additional fake edges. It's better to have a single blurred edge.