Information on Aliasing Project


Chris Wyman



Overview of Code

Below is an overview of the code. This is organized into two parts: (1) a high level description of the steps that the program goes through, and (2) a description of how the code is organized into files.

Steps in the Program

  1. Interpret the command line.
  2. Read in the source image provided on the command line.
  3. Transform the image into the Fourier domain (using the FFT).
  4. Write the power spectrum out to file.
  5. Perform the filter selected by the user on the command line.
  6. Write the filtered power spectrum out to file.
  7. Perform the inverse Fourier transform (using the inverse FFT).
  8. Write the filtered image to file.
  9. Perform cleanup.

Organization by File



Running & Compiling the Program

The program is very easy to run. Run "aa" (with no parameters) to get usage information. Generally, for fourier domain filters, there are 3 command line requirements: (1) the input file (2) the filter number, and (3) a parameter to the filter.

Examples:


These are the five frequency domain filters & parameters that will give decent results. The parameters can be varied within an order of magnitude or two, depending on the filter.

Compiling the program is simple: run the 'build' script I handed in with the code, or compile with the command line "cc -03 -o aa *.c -lm"

WARNING: The code has only been tested on the SGI I use. That's not to say it won't work on other machines, but I haven't tested it on others.




Images/Results

The first step in testing my program was to check to make sure that the Fourier Transform code actually worked, to do this, I tested a white square on a black background, and then inverted the image to make sure that I got back the original. I did. Below are the original and the image in the fourier domain:


Original image

Power spectrum of the original

NOTE: To scale the power spectrum so that it is visible, I scaled the average value to a grayscale value of 128. Obviously (as can be seen above), this decreases contrast on the high end, where everything is white, but it allows much more of the power spectra to be seen in detail than the other methods of scaling that I tried.

Image of Zion National Park

This is probably the best test image I have, so I'll look at these results in more detail than the others. I didn't have time to find other images that caused good aliasing when just subsampled, though I do provide some results for a few other images.


Original image subsampled (405x270)

Power spectrum of the original image

The original image is provided on a separate page later. Notice that the subsampled image has serious aliasing artifacts...

Below are the power spectra for the five filters I have implemented for this assignment. Once again, the scaling washes out some of the spectra, but around the origin, all the spectra look relatively similar is they were scaled by the same factor.


Of the original

Of the image filtered by sinc(s)*sinc(t)

Of the image filtered by sinc2(s)*sinc2(t)

Of the image filtered by a gaussian

Of the image filtered by a strict lowpass filter

Of the image filtered by a sinc(sqrt(s2+t2))

And below are the filtered & subsampled images resulting for each of the above filters. Note that my inverse fourier transform gives me an image which has dimensions which are a power of two. Thus, any black edges around the images below are just a result of my sloppy cropping job.


Subsampled original

Image filtered by sinc(s)*sinc(t)

Image filtered by sinc2(s)*sinc2(t)

Image filtered by a gaussian

Image filtered by a strict lowpass filter

Image filtered by a sinc(sqrt(s2+t2))


Image of a Nebula

The following image is an image from teh Hubble Space Telescope. It isn't particularly aliased when supbsampled, but I ran my program on it to see the results anyways. Also, I separated the red, green, and blue channels seperately when computing the fourier transforms.


Original, subsampled image


Image filtered with a gaussian

Original image's power spectra (combined rgb)

Red filtered power spectrum

Green filtered power spectrum

Blue filtered power spectrum



Other Test Images

More images will be on my web page tomorrow or Wednesday once I have a chance to organize them into HTML form. They'll be at: http://www.cs.utah.edu/~wyman/classes/imp/index.html below the images from Project 1.




Discussion


I'm not exactly sure what sort of analysis you were looking for, but hopefully this covers most of it:

Energy Loss

Since these filters apply some function to the forier domain, they cause changes in the power spectra, thus reducing the total energy. The original energy is |F(s,t)|2 intergrated over s, and t. The filters thus cause a reduction in energy of (1-func(s,t))*|F(s,t)|2 integrated over s, and t, where func(s,t) is the filter function (for example sinc(s)*sinc(t) for the sinc function).

You can see this in the images, as a smoothing out of the image and a reduction of high frequency noise and detail, as well as in the fourier domain, where all the higher frequencies, which were more or less evenly represented have been drastically reduced by the filtering function.


Foldback Error

The lowpass and gaussian filters both have little or no foldback error (for most values of the input parameter) because they limit the frequencies in the fourier domain used in image reconstruction to the lower frequencies, and thus eliminate the higher frequencies, where more leaking is bound to occur. However, the biggest problem with these filters is that they also have a larger in-spectrum energy loss, causing substantial blurring to the reconstructed, losing some of the detail that we'd rather keep.

The sinc based functions all have a larger foldback error, keeping the potential for aliasing, even in the "antialiased" images. These functions keep higher frequencies in the power spectra, which adds to the foldback error, but keeps the fidelity of the images higher. In the sinc and circular sinc filters, you still see some of the aliasing of the original image (though not as much as was there originally). In the sinc2 filter, you see less aliasing from foldback because squaring the sinc function reduces still further the higher frequencies used to reconstruct the image.