# F06 Fun With Sines

In this assignment you will construct graphs and images of functions. Your goals are to get familiar with a set of tools for

working with images and to observe the effects of sampling. You may use Matlab, Python or your own code for this assignment.

Part 1

———

Consider the function I=128*sin(2*pi*f*(X-250))+128 for values of X varying from 1 to 500. Observe both a 2D plot of I versus X and a 500×500 image with X varying left to right and all scan lines identical. For example, in Matlab you might type:

X = 1:500;

I = 128 * sin(2*pi*f*(X-250)) + 128;

plot(X,I);

For your image, let X vary in steps of 1 so that X is the column number from left to right. I might construct the image with the following rather obscure matlab code:

X = 1:500;

I = 128 * sin(2*pi*f*(X-250)) + 128;

im = repmat(I, 500, 1);

image(im);

colormap(gray);

You can read about all these functions in the Matlab help. The point is to construct an image with sine waves varying in the horizontal direction and all scan lines identical. The image is gray-scale, and the pixel values vary from 0 to 1.

Look at plots with f varying from 0 to 1. Pay special attention to how the image behaves near f=0.5. I suggest that you carefully examine images with f = 0.4, 0.45, 0.49, 0.495, 0.5, 0.51, 0.6, 0.8 etc. until you feel that you can explain what you are seeing.

Produce a simple writeup of your results including a few images to support your explanation. You can make a web page, or a PDF.

Describe how you made the plots and the images and what you observed as the frequency of the sines increased. Convince me that you understand what you saw. What did you see when the frequency was exactly 0.5? Why? Suppose you shifted the phase of the sine by pi/2, what would you see at f=0.5? There is no need to load your page down with images, just explain what you saw. If a graph or image is really necessary for your explanation, then use it.

Part 2

———

In class I described how the DFT can be represented as a matrix multiply. Implement a function that given an integer N, creates the NxN matrix M such that M * X is the DFT of the vector X. Compare your M * X with the output of fft(X). How do they differ? Have your function normalize M so that it is orthonormal. Demonstrate (for some small N) that M is indeed orthonormal. For M of size 100×100, make an image (with imagesc) of its real part. Make another image of its imaginary part. What do you learn about the structure of the DFT from these images?

Part 3

———

Read about the Fast Fourier Transform. Write a short description (about 1 page of text when viewed on a web browser) of how it works and why it uses so many fewer operations than the matrix defined above.

1 comments

AStudent -- Monday, October 16, 2006 at 10:04 PM