Project 03

Due Thursday, October 11, 2012

Problem 1 (15 points)

In Notebook 032 you have seen how to convert a color image to its YCbCr components. Recreate the original color image from its Y-, Cb- and Cr- components. (Check your result by computing the Peak Signal to Noise Ratio to the original image. Note that when computing the luminance/chrominance components, we round to the nearest integer. )

SetDirectory[NotebookDirectory[]];<<DW.m;

pic=Import["Images\\Color\\waves_small.png","Data"];
ImagePlot[pic]

fct=({16+1/256(65.738#[[1]]+129.057#[[2]]+25.064#[[3]]),128+1/256(-37.945#[[1]]-74.494#[[2]]+112.439#[[3]]),128+1/256(112.439#[[1]]-94.154#[[2]]-18.285#[[3]])}&);
YCbCr=Round[Map[fct,pic,{2}]];
Y=YCbCr[[All,All,1]];
Cb=YCbCr[[All,All,2]];
Cr=YCbCr[[All,All,3]];

Grid[{{ImagePlot[Y],ImagePlot[Cb],ImagePlot[Cr]}}]

Problem 2 (15 points)

The problem will use the command 'FourierSCPlot':

?FourierSCPlot

By the way, you can create π by either writing 'Pi' or by pressing 'ESCpESC'.

Pi
N[Pi]

Consider the following function :

f[x_]=Piecewise[{{-1/2,x<0},{1/2,x>0}}];
Plot[f[x],{x,-π,π},PlotStyle->{Blue,Thick}]

Below is the graph of f(x) again (dashed) and the graph of its 8th "degree" Fourier approximation (green) :

FourierSC[f[x],x,8]

FourierSCPlot[f[x],x,8]

We can use ' PlotRange' to zoom in, and notice that - in the worst case scenario -  the value of the function f(x) differs from its Fourier approximation by about  Δy=0.092; the "first" peak of the Fourier approximation happens at a distance of about Δx=0.39 from the point of discontinuity of the function:

Here is the same plot without the blue lines :

FourierSCPlot[f[x],x,8,GridLines->Automatic,PlotRange->{{.0,.5},{.49,.6}}]

1. How do these values of Δx and Δy change when you increase the number of terms of the Fourier approximation? 
2. Repeat 1. for the function g(x):

g[x_]=Piecewise[{{-1,x<0},{1,x>0}}];
Plot[g[x],{x,-π,π},PlotStyle->{Blue,Thick}]

3. Repeat 1. for the "sawtooth" function h(x) :

h[x_]=Piecewise[{{(x+π)/π,x<0},{x/π,x>0}}];
Plot[h[x],{x,-π,π},PlotStyle->{Blue,Thick}]

4. Summarize your findings : How do the values Δx and Δy depend on the degree of the approximation? How do they depend on the size of the "jump" at x = 0? Do they depend on the shape of the function? What other observations can you make?