Project 02

Last edit 2/11/2026

Project 2

Problem 1

Pick a small grayscale image (your choice) and use only matrix transposition and multiplication with suitable matrices to produce the following six images :

Problem 2

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.wl;

photo=;
pic=ImageData[photo,"Byte"];
ImagePlot[pic]

fct[v_]:={16+1/256(65.738v[[1]]+129.057v[[2]]+25.064v[[3]]),128+1/256(-37.945v[[1]]-74.494v[[2]]+112.439v[[3]]),128+1/256(112.439v[[1]]-94.154v[[2]]-18.285v[[3]])};

An example: If the RGB values of a pixel are 10, 100, and 200, respectively, the next command produces the YCbCR values (not rounded).

fct[{10,100,200}]
Round[fct[{10,100,200}]]

YCbCr=Round[Map[fct,pic,{2}]];
Y=YCbCr[[All,All,1]];
Cb=YCbCr[[All,All,2]];
Cr=YCbCr[[All,All,3]];
ImagePlot[Y]
ImagePlot[Cb]
ImagePlot[Cr]

Problem 3

In Notebook 031  a "resampling" algorithm is shown that cuts the number of rows and columns of an image in half.  Suppose you want to reduce the number of rows and columns of an image by 20. One  idea is to delete every fifth row and column, but this leads to unsatisfactory results (see example below). Can you come up with an idea for an improved algorithm that may lead to better results? Briefly describe such an algorithm, i.e. the matrices you would multiply the original image by. (No coding in Mathematica is required.) It may be advantageous to first think about this problem in one dimension (for a vector).