Posts Tagged ‘optics’

Matlab FFT Tutorial

Monday, February 23rd, 2009

compliments of xkcd.com

compliments of xkcd.com

Taking fourier transforms of things is really popular nowadays, especially in the realm of discrete time-signal analysis and also image processing.  I am in the process of learning how to use fourier transform analysis to extract the phase of interferometric images (read: holograms), but more on that another day.

Matlab is absolutely great for doing numerical simulations with large datasets, but I find it has some major shortcomings when it comes to fourier transforms, and really everything else analytical.  Mathematica wins here, except for needing a couple custom parameters to produce a unitary fourier transform of a function.  However I have managed to find a pretty nice work around for Matlab’s fast fourier transform function (’FFT’).  The three main issues that arise with FFTs are:

  1. Frequency scaling doesn’t work out properly (ie - FFT(sin(x)) does NOT give you a peak at 2π automatically)
  2. Positive and negative frequencies get all mixed up.
  3. Apparently the amplitude is off too.

Quan Quach at blinkdagger has come up with a very convenient function script that deals with these problems on a basically satisfactory level.  I’d like to delve further into what this does and how to extract meaningful data from a Matlab FFT, but I think I’ll save that for a future post.  Looks like Quan has a full category on fourier transforms, which is a MUCH better place to start than the matlab help file for FFT or FFT2 (2-dimensional version of the fourier transform).  Check it out here.

You’ll learn how to take this:

… and produce this:

Really quite nifty!  While this got me started with fourier transforms, I’d really like to dig into the meaning of fourier transforms of space and digital image processing.  In the world of optics, this gives a lot of helpful knowledge when processing data from lens focal planes, from holograms, or even when numerically simulating an electromagnetic field and you’re interested in far-field diffraction patterns.  Actually on that note, it’s time for me to get back to my homework…

Tags: , , , ,
Posted in signal processing | No Comments »