Problem #7a


The program hw7_a.m implements a Gaussian filter of specified variance Var. I chose three different variances: Var = 0.5, 1.5, 2.5. I didn't want to set the variance smaller than 0.5, because the images didn't show much change for smaller variances. Also, a variance larger than 2.5 seemed to blur the image too much. Each Gaussian was placed on a 7x7 mask. The Gaussians are shown below.


Var = 0.5

Var = 1.5

Var = 2.5

First, I ran the Gaussian filter on the original image cameraman.tif. As the variance increases, the amount of blurring increases.


Original image

Var = 0.5

Var = 1.5

Var = 2.5

Next, I added salt & pepper noise to the original image in matrix A using the command:
imnoise(A,'salt & pepper',0.03)
The Gaussian filter did not really remove the noise. It really just blurred the image and made the noise points less extreme. A larger variance would probably remove the noise better, but that would also blur the image too much. The median filter does a much better job in removing salt & pepper noise.


Salt & Pepper Noise

Var = 0.5

Var = 1.5

Var = 2.5

Finally, I added Gaussian noise of mean 0 and variance 0.01 to the image A by using:
imnoise(A,'gaussian',0,0.01)
The Gaussian filter seems to handle this noise better. The noise is smeared into the image. Still, as the variance increases, the image gets more blurred.


Gaussian Noise

Var = 0.5

Var = 1.5

Var = 2.5


Source Code: hw7_a.m
Back to HW 1 Page.