<< Chapter < Page | Chapter >> Page > |
where is a suitably chosen window. [link] shows the performance of the median filter in reducing so-called"salt and pepper" noise.
Download the files race.tif , noise1.tif and noise2.tif for this exercise. Click here for help on the Matlab mesh command .
Among the many spatial lowpass filters, the Gaussian filter is of particular importance.This is because it results in very good spatial and spectral localization characteristics.The Gaussian filter has the form
where , known as the variance , determines the size of passband area. Usually the Gaussian filter is normalized by a scaling constant such that the sum of the filter coefficient magnitudes is one, allowing the average intensity of the image to be preserved.
Write a Matlab function that will create a normalized Gaussian filter that is centered around the origin (the center element of your matrix should be ). Note that this filter is both separable and symmetric , meaning and . Use the syntax
h=gaussFilter(N, var)
where
N
determines the size of filter,
var
is the variance, and
h
is the
filter. Notice that for this filter to
be symmetrically centered around zero,
will need to be an odd number.
Use Matlab to compute the frequency response of a Gaussian filter with . Use the command
H = fftshift(fft2(h,32,32));
to get a
DFT.
Plot the magnitude of the frequency responseof the Gaussian filter,
, using the
mesh
command. Plot it over the region
,
and label the axes.
Filter the image contained in the file race.tif with a Gaussian filter, with .
Y=filter2(h,X);
,
where
is the matrix containing the input image and
is the impulse response of the filter.Now write a Matlab function to implement a
median filter (without using the
medfilt2
command).
Use the syntax
Y = medianFilter(X);
where X and Yare the input and output image matrices, respectively.For convenience, you do not have to alter the pixels on the border of .
median
to find the median value of
a subarea of the image, i.e. a
window surrounding each pixel.Download the image files
noise1.tif and
noise2.tif .
These images are versions of the previous
race.tif image that have been degraded by
additive white Gaussian noise and "salt and pepper" noise, respectively.Read them into Matlab, and display them using
image
.
Filter each of the noisy images with both the
Gaussian filter (
) and the
median filter.
Display the results of the filtering, and place a title on each figure.(You can open several figure windows using the
figure
command.)
Compare the filtered images with the original noisy images.Print out the four filtered pictures.
gaussFilter
and
medianFilter
.Image sharpening techniques are used primarily to enhance an image by highlighting details. Since fine details of an imageare the main contributors to its high frequency content, highpass filtering often increases the local contrast and sharpens theimage. Some typical highpass filter impulse responses used for contrast enhancement are shown in [link] . The frequency response of each of these filters is shown in [link] .
An example of highpass filtering is illustrated in [link] . It should be noted from this examplethat the processed image has enhanced contrast, however it appears more noisy than the original image.Since noise will usually contribute to the high frequency content of an image, highpass filtering has the undesirable effect of accentuatingthe noise.
Download the file blur.tif for the following section.
In this section, we will introduce a sharpening filter known as an unsharp mask . This type of filter subtracts out the “unsharp” (low frequency) componentsof the image, and consequently produces an image with a sharper appearance.Thus, the unsharp mask is closely related to highpass filtering. The process of unsharp masking an image can be expressed by
where is a lowpass filter, and and are positive constants such that .
Analytically calculate the frequency response of the unsharp mask filter in terms of , , and by finding an expression for
Using your
gaussFilter
function from the
"Smoothing Exercise" section,
create a
Gaussian filter with
.
Use Matlab to compute the frequency response of an unsharp mask filter(use your expression for
[link] ), using
the Gaussian filter as
,
and
.
The size of the calculated frequency response should be
.
Plot the magnitude of this response in the range
using
mesh
, and label the axes.
You can change the viewing angle of the mesh plot with the
view
command.
Print out this response.
Download the image file
blur.tif and read it into Matlab.
Apply the unsharp mask filter with the parameters specified aboveto this image, using
[link] .
Use
image
to view the original and processed images.
What effect did the filtering have on the image? Label the processedimage and print it out.
Now try applying the filter to blur.tif , using and . Compare this result to the previous one. Label the processedimage and print it out.
Notification Switch
Would you like to follow the 'Purdue digital signal processing labs (ece 438)' conversation and receive update notifications?