> I wanted too to:
> 1) calculate the spectrum of an image
> 2) modify the spectrum
> 3) apply a reverse fourier transform to see modifications on the original
> picture (strioscopy, foucaultage).
> But I don't know how to perform a reverse fourier transform with scilab.
Hello, Jocelyn,
Sorry for the long delay. It is a bit confusing to use the DFT, but it
is not hard once you get used to it. (I apologize if you already know
some of the stuff I'm going to say).
It seems that all you want is to calculate the image power spectrum centered
on the array.
It is simple:
// im is a grayscale image
IM = fft(im,-1);
// powerspectrum = |IM|^2
// (you could use only abs, too).
spectrum = abs(IM).*conj(IM)
// to center the power spectrum
spectrum = fftshift(spectrum);
imshow(spectrum,[]);
To visualize low frequencies, I don't think you need to threshold
like you did:
imshow(log(spectrum + 1),[])
That simple trick greatly enhances the pow.spectrum (see Gonzalez & Woods
Digital Image Processing book).
// reverse tranform
im2 = real( fft(IM,1) );
To modify the spectrum and take the inverse fft, the code of SIP's
gsm2d helps you understand how it is done. Roughly speaking, you have
to remind that Discrete Fourier Transforms understand the spectrum as
a finite window of a period over the whole continuous infinite
spectrum with period T. By convention (I guess) DFTs choose NOT the
window _arround_ the origin, but the window _starting_ at the origin.
So what you have to do is:
1 - Modify the spectrum. Before this, centralize it if you want
(using fftshift), or calculate shifted coordinates, like I did
in gsm2d.
2 - Pass it to the inverse FFT. HOWEVER, if you used fftshift,
you must first use it again to re-wrapp your image to the
conventional form that FFT understands it.
BTW, I saw in the help file that you use the following construct to
show an image and normalize it:
imshow(normal(spectrum1,255,0));
It is equivalent and easier like this:
imshow(spectrum1,[]);
Thanks again for your active engagement in SIP development.
Ricardo.
--
Ricardo Fabbri, Cybernetic Vision Research Group, USP, Brazil.
www.rfabbri.kit.net
"Quality and Quantity are both good, but nowadays we miss Quality"
|