hi... Today we are going to learn about removing Noise in Image using MATLAB.
Digital images are prone to a variety of types of noise. Noise is the result of errors in the image acquisition process that result in pixel values that do not reflect the true intensities of the real scene. There are several ways that noise can be introduced into an image, depending on how the image is created. For example:
- If the image is scanned from a photograph made on film, the film grain is a source of noise. Noise can also be the result of damage to the film, or be introduced by the scanner itself.
- If the image is acquired directly in a digital format, the mechanism for gathering the data (such as a CCD detector) can introduce noise.
- Electronic transmission of image data can introduce noise.
To simulate the effects of some of the problems listed above, the toolbox provides the
imnoise
function, which you can use to add various types of noise to an image. The examples in this section use this function.Remove Noise By Linear Filtering:
You can use linear filtering to remove certain types of noise. Certain filters, such as averaging or Gaussian filters, are appropriate for this purpose. For example, an averaging filter is useful for removing grain noise from a photograph. Because each pixel gets set to the average of the pixels in its neighborhood, local variations caused by grain are reduced.
See What Is Image Filtering in the Spatial Domain? for more information about linear filtering using
imfilter
.
EXAMPLE:
Read a color image into the workspace and view it.
originalRGB = imread('peppers.png');
imshow(originalRGB)
Fig:Original Image
Create a filter,
h
, that can be used
to approximate linear camera motion.
h
= fspecial('motion', 50, 45);
Apply the filter, using
imfilter
, to
the image originalRGB
to create a new image, filteredRGB
.
filteredRGB
= imfilter(originalRGB, h);
figure,
imshow(filteredRGB)
Fig:Filtered Image
Remove Noise Using Median Filtering
This example shows how to remove salt
and pepper noise from an image using an averaging filter
and a median filter (
medfilt2
) to allow comparison
of the results. Median filtering is similar to an averaging filter,
in that each output pixel is set to an average of the pixel values
in the neighborhood of the corresponding input pixel. However, with
median filtering, the value of an output pixel is determined by the median of
the neighborhood pixels, rather than the mean. The median is much
less sensitive than the mean to extreme values (called outliers).
Median filtering is therefore better able to remove these outliers
without reducing the sharpness of the image. Median filtering is a
specific case of order-statistic filtering, also
known as rank filtering. For information about
order-statistic filtering, see the reference page for the ordfilt2
function.
Example:
Read image and display it.
I
= imread('eight.tif');
imshow(I)
FIG:Input Image
For this example, add salt and pepper noise to the image.
This type of noise consists of random pixels being set to black
or
white (the extremes of the data range).
J
= imnoise(I,'salt & pepper',0.02);
figure,
imshow(J)
Fig:Salt & Pepper Noise added Image
Filter the noisy image with an averaging filter and display
the results. The example uses a 3-by-3 neighborhood.
K
= filter2(fspecial('average',3),J)/255;
figure,
imshow(K)
Fig: Noise Removed image
Now use a median filter to filter the noisy image and
display the results. The example uses a 3-by-3 neighborhood. Notice
that
medfilt2
does a better job of removing noise,
with less blurring of edges.
L
= medfilt2(J,[3 3]);
figure,
imshow(L)
Fig: Noise Removed by Median Filter
Remove Noise By Adaptive Filtering:
The
wiener2
function
applies a Wiener filter (a type of linear filter) to an image adaptively, tailoring
itself to the local image variance. Where the variance is large, wiener2
performs
little smoothing. Where the variance is small, wiener2
performs
more smoothing.
This approach often produces better results than linear filtering.
The adaptive filter is more selective than a comparable linear filter,
preserving edges and other high-frequency parts of an image. In addition,
there are no design tasks; the
wiener2
function
handles all preliminary computations and implements the filter for
an input image. wiener2
, however, does require
more computation time than linear filtering. wiener2
works best when the noise is constant-power
("white") additive noise, such as Gaussian noise. The
example below applies wiener2
to an image of Saturn
that has had Gaussian noise added.
1.Read in an image. Because the image is a truecolor image,
the example converts it to grayscale.
RGB
= imread('saturn.png');
I
= rgb2gray(RGB);
2.The example then add Gaussian noise to the image and then
displays the image. Because the image is quite large, the figure only
shows a portion of the image.
J
= imnoise(I,'gaussian',0,0.025);
imshow(J)
Fig:Portion of the Image with Added Gaussian Noise
3.Remove the noise, using the
wiener2
function.
Again, the figure only shows a portion of the image
K = wiener2(J,[5 5]);
figure, imshow(K)
Fig:Portion of the Image with Noise Removed by Wiener Filter
Thank you... will see you with next interesting topic....
No comments:
Post a Comment