title: Approximating a shape boundary using Fourier descriptors
body: <p>I am trying to approximate shape boundaries by using Fourier descriptors. I know this can be done because I've learned about it in class and read about it in several sources.</p>
  
  <p>To obtain the Fourier descriptors of a boundary of (x,y) coordinates, I do the following:
  1) Turn (x,y) coordinates into complex numbers of the form x + iy
  2) Feed this new set of numbers into the 1D Fourier transform
  3) The output are the Fourier descriptors</p>
  
  <p>To approximate the boundary, I simply remove (set to zero) the high frequencies, then apply the inverse Fourier transform, then convert the complex numbers back to (x,y) coordinates, and then reconstruct the image from this new set of coordinates. The goal of my project is to find out how well I can approximate boundaries depending on how many of the terms I set to zero.</p>
  
  <p>My problem is that whenever I set ANY of the frequencies to 0, my output image is very small and comes out as very weird patterns. </p>
  
  <p>I've included an example below. The input image is a normal square. The first output image given is the reconstruction of the image using all the Fourier descriptors as normal. Note that the whole boundary is not there because the number of boundary pixels was sampled to 256 and I didn't bother connecting the dots when I output. Also note that the output is translated to the bottom left corner, this was on purpose. The second output image is when I use only the first 128 frequencies.</p>
  
  <p><a href="http://img19.imageshack.us/my.php?image=square0.bmp" rel="nofollow noreferrer">Input Image http://img19.imageshack.us/my.php?image=square0.bmp</a></p>
  
  <p><a href="http://img27.imageshack.us/my.php?image=square0normal.bmp" rel="nofollow noreferrer">Output Image 1: All frequencies http://img27.imageshack.us/my.php?image=square0normal.bmp</a></p>
  
  <p><a href="http://img23.imageshack.us/my.php?image=square0out.bmp" rel="nofollow noreferrer">Output Image 2: First half of frequencies http://img23.imageshack.us/my.php?image=square0out.bmp</a></p>
  
  <p>Does anyone have any idea why this might be happening?</p>
  
  <p><strong>Edit:</strong> First time putting images on here, not sure why they aren't showing up.. here are the links:<br>
  <a href="http://img19.imageshack.us/my.php?image=square0.bmp" rel="nofollow noreferrer">Input image</a><br>
  <a href="http://img27.imageshack.us/my.php?image=square0normal.bmp" rel="nofollow noreferrer">Output1</a><br>
  <a href="http://img23.imageshack.us/my.php?image=square0out.bmp" rel="nofollow noreferrer">Output2</a>  </p>
  
  <p>Also here is a <a href="http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MORSE/boundary-rep-desc.pdf" rel="nofollow noreferrer">link to a document that talks about this a bit</a>, it starts at the end of page 5.</p>