HW 5, Problems 1-9
EECS 203A, UCI, Fall 2004

by Nasser Abbasi

Question

TextBook: Digital Iage Processing, 2nd edition. By Gonzalez and Woods.

The white bars in the test pattern shown below are 7 pixels wide and 210 pixels high. The separation between bars is 17 pixels. What would this image look like after application of 
(a) 3x3 Arithmetic mean filter?
(b) 7x7 AMF?
(c) 9x9 AMF?

Answer

Load the original Image and display it first. I downloaded the image from the text book website, and used InfranView to get the image information to find how many pixels the whole image is, then read in into Mathematica to display it.

Clear["Global`*"];
nma`cd;
nRow = 256; 
nCol = 256;
data = 
        nma`imread["Prob5.01.raw", 256, 
          256];
nma`imshow[data, "problem 5.1 image"]

Now construct each ARM filter, and apply them to the above image

ARM[n_] := 
      Table[(1/(n^2)), {i, 1, n}, {j, 1, n}]
ARM3 = ARM[3];
MatrixForm[ARM3]

Filter the image with ARM3 and display result

nImage3 = nma`filter[data, ARM3];
nma`imshow[nImage3, "ARM 3x3"]

Now do the same with 7x7 ARM

ARM7 = ARM[7];
MatrixForm[ARM7]
nImage7 = nma`filter[data, ARM7];
nma`imshow[nImage7, "ARM 7x7"]

Now do the same with 9x9 ARM

ARM9 = ARM[9];
MatrixForm[ARM9]
nImage9 = nma`filter[data, ARM9];
nma`imshow[nImage9, "ARM 9x9"]

Analysis

In the original image, the vertical white bars look like this (displaying the top end of the white bar) we see that the white bar top starts at row number 24, we see that the strip is 7 pixels wide.

Take[data, {23, 27}, {26, 34}] // MatrixForm

After applying the 3x3 filter, the white bar would blur to the following

Take[Round[N[nImage3]], {20, 27}, {23, 35}] // MatrixForm

So we see that the white bar is 9 pixels wide, and now starts at row 22, so it has added 2 rows at the top (and 2 rows at the bottom by symmettry), hence it will be of 214 pixels high. We also see the effect of averaging is to give smooth boundaries.

Do similar analysis on the 7x7 filter.

Take[Round[N[nImage7]], {16, 25}, {19, 35}] // MatrixForm

We see that now the white bar is 13 pixels wide, and starts at row 18, so it has added 6 rows at the top and 6 rows at the bottom, so it is now 222 pixels high. we see that the edges now are more smooth.

Do similar analysis on the 9x9 filter.

Take[Round[N[nImage9]], {14, 26}, {17, 35}] // MatrixForm

We see that now the white bar is 15 pixels wide,and starts at row 16,so it has added 8 rows at the top and 8 rows at the bottom,so it is now 216 pixels high. we see that the edges now are even more smooth.