Contents
Hello world,
I routinely simulate forward imaging in optical systems to understand how they function. One of the beautiful phenomena of optics is that a lens is a fourier transformer. It produces 2D fourier transform of field between planes located one focal length away on either side of itself. MATLAB is a ‘matrix laboratory’, so it implements discrete Fourier transform (DFT). The standard way of implementing DFT is FFT (Fast fourier transform) algorithm.
Although I have been using MATLAB since 6 years, I never quite grasped the interplay of fft, ifft, fftshift, and ifftshift functions found in MATLAB. Well, the penny dropped today after a comment from Steve on his blog that fftshift and ifftshift cause circular shifts and nothing more. By the way, Steve’s image processing blog is one of the most useful blogs and these days he is clarifying how Fourier transforms work in MATLAB. He just described that FFT algorithm inherently assumes that the function is periodic in both space and frequency. This occurs because whenever one of the domain (space or spatial-frequency) is sampled, its Fourier counterpart becomes periodic. Multiplication with impulse train (i.e., discretization) in one domain leads to convolution with impulse train in the other domain (i.e., periodicity). In DFT, both space and spatial-frequency are discrete (actually digital), and therefore, both domains are periodic.
The problem – Fourier transform of a real and even function.
Typical functions that occur in optics (e.g., pupil of an imaging system which is simply a circle) are real and even around origin (i.e., optical axis). We expect the Fourier transform or inverse Fourier transform of a real and even function to be real and even itself. However, I had trouble achieving this seemingly basic task. After good amount of experimentation, I had decided that the the idiom spec = fftshift(fft2(ifftshift(signal))) gives real and even spectrum for real and even signal. However, I understood why that is the case just recently.
(more…)
Categories: MATLAB/Mathematica · optics · signal processing
Tagged: fft, fftshift, ifft, ifftshift
As I noted in the previous post about FiO, I wish to share some of the simulations and basics about phase-space signal analysis. While doing simulations, I sometimes find it tricky to interpret analog equations and convert them to a sequence of programmed operations on discrete data. Also, one needs to be careful about not losing information when going from analog to discrete domain. This all-important step is known as A to D (analog to *discrete*) conversion and is responsible for Nyquist and Shannon being so famous.
I rely on two tools for my modeling needs: MATLAB (TM) most of the time and Mathematica (TM) sometimes. Mathematica is excellent for allowing quick visualization of the model due to its ability to work directly with symbols, whereas MATLAB is good for fast and maintainable implementation. It may be possible to write maintainable code in Mathematica but that requires going through steep learning curve, especially for folks who had learned classic ‘C’ as their first language. Is there a way of marrying symbolic ease of Mathematica with programming ease of MATLAB? I seem to have found one using anonymous functions. The code used in this post has been posted here on MATLAB file-exchange, which will be available within a day after moderation.
Let us consider the problem of calculating instantaneous correlation (which is a primary quantity required to compute and understand the Wigner distribution and Ambiguity function). For a signal
it is defined as,

We know that the auto-correlation of a function is defined as
Thus, we see that instantaneous correlation is in some sense the quantity which when integrated along
gives us the auto-correlation function.
As we shall see in upcoming posts, Wigner distribution is the Fourier transform of the instantaneous correlation (Icorr) along the delay (
) dimension, whereas the Ambiguity function is Icorr’s Fourier transform along the normal (
) dimension. Therefore, there are two ways of interpreting what the instantaneous correlation is:
-
is the signal which is shifted by
and
The conjugate of the delayed version (
) when multiplied with the advanced version (
) gives us Icorr.
-
is the signal which is first dilated to give us
This dilated signal’s conjugate is flipped to give
The signal
is advanced to give
and the
signal is delayed to give us 
As is often the case – hindsight is 20/20. I could write above paragraph so clearly because I have already gone through simulating the problem with two tools. But things should be presented logically and not chronologically, so I explained the model first. Next are the simulations. (more…)
Categories: FiO09 · MATLAB/Mathematica · signal processing
Tagged: anonymous functions, instantaneous correlation, symbolic computation, wigner distribution