Introduction to the Fourier Transform

Theory behind Fourier Transform

The Fourier Transform (FT) is a linear transformation of f(x) to g(1/x). A common use of this is to convert an image (function of space) into a function of its spatial frequency. While this may useless at the moment, some operations and properties are easier or more obvious when done in the spatial frequency domain, instead of in the usual space domain.

This blog shall cover some basic properties and uses of the Fourier Transform.

Area Estimation

Hello again!

In line with the theme of AP 186 of using digital means to calculate physical and meaningful values, this time, we will be numerically obtaining areas of shapes.

Why is this important? Can’t we just get a ruler and measure the sides? What if the object is so small that 1,000,000 of it can fit between the smallest gradient of your ruler? Or what if the object is irregular and has no exact formula for its area?

This technique can also be used to measure and effectively monitor biological cells, such as to monitor their size and growth. It can also be used in detecting defects in very small objects where only optical techniques, and hence pictures, can detect them.

So how do we numerically calculate the area of any given shape? Well, we will be using Green’s Theorem, which relates a double integral (area) to a line integral(edge). This technique is good for shapes where the edge is very well defined (such as black and white shapes).

For brevity, I will not be including the derivation, but the formula for area using Green’s Theorem is as follows:

Formula for area using Green's Theorem.
Formula for area using Green’s Theorem.

(I did not derive this. Thank you Ma’am Jing Soriano for providing us with the very helpful hand-outs.)

The variables x and y represent the coordinates of the points along the edge of the shape, and are ordered such that they trace a counterclockwise path around the shape. Thus, to get the area, all we need to do is to extract the coordinates of the edge, and order them properly. Sounds easy, right? Maybe. We shall see.

Method

Before I continue, I would again like to acknowledge Ma’am Jing Soriano for providing us with the outline for the method. (We still have to do the coding ourselves, which is also fine.)

  1. Convert shape to a binary (i.e. B&W) image to make detecting the edge easier.
  2. Extract the edge by using the edge function.  This returns a binary matrix with 0’s and 1’s, where a 1 represents an edge point.
  3. Get the coordinates of the edge using find.
  4. Convert these coordinates to polar coordinates centered about the centroid of the image.
  5. Order the coordinates according to increasing theta.
  6. Convert coordinates back to Cartesian coordinates.
  7. Calculate area using the formula.
  8. Debug your code.
  9. Debug again.
  10. Celebrate!