problem 7

In this problem you will implement a spatial-domain low-pass filter using matlab and evaluate the difference between the filtered image and the original image using two quantitative metrics called

How to calculate each

Given two \(N_1\) x \(N_2\) images \(x(n_1, n_2)\) and \(y(n_1, n_2)\)

MSE is computed via:

\(MSE = \frac{1}{N_1 N_2} \sum_{n_1 = 1}^{N_1} \sum_{n_2 = 1}^{N_2} [x(n_1,n_2) - y(n_1,n_2)]^2\)

I tried to find if my stats book had mean standard error with a similar equation. I did not find it, but here is the wikipedia definition which does have some variables from stats, ie. sample. Considering its squared, we have \(\frac{1}{n}\) instead of \(\frac{1}{\sqrt{n}}\)

\(MSE = \frac{1}{N} \sum_{i = 1}^{n} [\hat{Y_i} - Y_i]^2\)

\(\hat{Y_i}\) is preditions or outcomes. Y is true values or input. n is number of samples in this case its the number of pixels. Since this is a 2d, he is using double summartion.

PSNR is computed via:

\(PSNR = 10 \log_{10} (\frac{MAX_I^2}{MSE})\)

Where \(MAX_I^2\) is the maximum possible pixel value of the images. For 8-bit gray-scale images this is 255.

Do the following to finish the problem.

  1. Download lena.gif which is 256x265x8-bit grayscale
  2. Convert the image from type uint8 to double.
  3. Create a 3x3 low-pass filter with all coefficients equal to \(\frac{1}{9}\) ie. create a 3x3 MATLAB array with all elements equal to \(\frac{1}{9}\).
  4. Low-pass filter the double array representing the input image with filter created above. This can be done using the MATLAB function imfilter. The function takes three arguments and returns one output.
    1. The first argument is the double input array.
    2. The second argument is the low-pass filter array.
    3. The third argument is a string representing the boundary filtering option. Use ‘replicate’ The output of imfilter is an array.
  5. Compute and record the PSNR between the input image and the output image.
  6. Repeat using a 5x5 low pass filter with all coefficients equal to \(\frac{1}{25}\)

For the submission, submit the PSNR result for the 3x3 followed by the 5x5 result. Use a space to seperate the results. Record digits to 2 decimal points.

Helpful MATLAB routines

  • imfilter - filter routine
  • imshow - display the image
  • imwrite - write the matrix to file