Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Strange object position after IFFT2
Replies: 3   Last Post: Dec 27, 2012 6:39 PM

 Messages: [ Previous | Next ]
 Wojtek Posts: 8 Registered: 5/7/12
Re: Strange object position after IFFT2
Posted: Dec 27, 2012 6:39 PM

"Image Analyst" wrote in message <kbig5o\$95s\$1@newscl01ah.mathworks.com>...
> "Wojtek" wrote in message <kbi4o4\$rbn\$1@newscl01ah.mathworks.com>...
> > I think I start to understand where is the problem. The whole thing concentrates in this simple piece of code which I prepared as an example:
> >
> > clear all
> > clc
> >
> > a = [zeros(1,412) ones(1,200) zeros(1,412)];
> > adft = fftshift(fft(a)) ;
> >
> > my_spectrum = zeros(1024,1024);
> > for k=1:1024
> > my_spectrum(k,k) = (adft(k)) ;
> > end
> > recon = (ifft2(ifftshift(my_spectrum))) ;
> > imagesc(abs(recon)) ;
> >
> > I calculated 1D FFT of a square function. I placed in in the diagonal of my empty spectrum. The result (the reconstructed image "recon") should be (in my opinion) one square function going diagonally through the center. So why as a result I get two rectangular functions - not one?

> ----------------------------------------------------------------------
> First of all, the FT of a rectangular pulse is a sinc function, not another rectangular pulse. Then you're taking just one sample from that 1D FFT signal and copying it to the output spectrum, but that sample that you're taking out of the sinc varies line by line. I have no idea why you'd want to do this. Then you're taking the ifft2 of a shifted spectrum and I have no idea why. The fftshift if mainly to make things look good for display and you really need good bookkeeping if you're going to start FFT'ing a shifted version. Normally you don't, unless it makes filtering easier, but in your case it doesn't. Why don't you post in the Answers forum and Wayne or Greg can explain better to you why your algorithm is messed up. I can't even figure out what this is supposed to do - I think you might have been better off just leaving your first question since this code just seems weird

and
> unrelated.

I'm not sure which part didn't you understand. I never said that FT of a square function is a square function. I said that after taking 1D FT of a projection, and putting it inside a 2D spectrum and then computing a IFFT2 of such created spectrum should give a rectangular function "projected" diagonally. That's what the Projection Slice Theorem says. Here's more about it:
http://engineering.dartmouth.edu/courses/engs167/12%20Image%20reconstruction.pdf page 12
I'm computing inverse Fourier Transform not of a shifted spectrum, but rather of a spectrum that is backshifted to the form, where 0 freq. is in the corner. It's obvious that I'm making some mistake, but your answer didn't quite help.

Date Subject Author
12/27/12 Wojtek
12/27/12 Wojtek
12/27/12 ImageAnalyst
12/27/12 Wojtek