Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
111
Chapter 4
Image Denoising using Interpolated Median Filter
4.1 Introduction
The image denoising methods fall into two broad categories: spatial
domain methods and frequency domain methods. The term spatial domain refers
to the image plane itself, and approaches in this category are based on direct
manipulation of pixels in an image. The frequency domain processing techniques
are based on modifying the Fourier transform of an image.
There is no general theory for image enhancement. When an image is
processed for visual interpretation, the viewer is the ultimate judge of how well a
particular method works. Visual evaluation of an image quality is a highly
subjective process, thus making the definition of a “good image” an elusive
standard by which to compare algorithm performance. When the problem is one
of the processing images for machine perception, the evaluation task is somewhat
easier. For example, in dealing with a character recognition application, and
leaving aside other issues such as computational requirements, the best image
processing method would be the one yielding the best machine recognition results.
However, even in situations when a clear-cut criterion of performance can be
imposed on the problem, a certain amount of trial and error is usually required
before a particular image enhancement approach is selected /1,2/.
As explained previously, the term spatial domain refers to the aggregate of
pixels composing an image. Spatial domain methods are procedures that operate
112
directly on these pixels. Spatial domain processes will be denoted by the
expression
)],([),( yxfTyxg (4.1)
where ),( yxf is the input image and ),( yxg is the processed image, and T is an
operator on f , defined over some neighborhood of ),( yx . In addition, the operator
T can operate on a single image or on a set of images, such as performing the
pixel-by-pixel sum of a sequence of images for noise reduction. Figure 4.1 shows
the basic implementation of equation 4.1 on a single image. The point (x, y)
shown is an arbitrary location in the image, and the small region shown containing
the point is a neighborhood of (x, y), and is much smaller in size than the image.
Figure 4.1: A 3 x 3 neighborhood about a point (x, y) in an image in the spatial domain
113
The process illustrated in figure 4.1 consists of moving the origin of the
neighborhood from pixel to pixel and applying the operator T to the pixels in the
neighborhood to yield the output at that location. Thus, for any specific location
(x, y), the value of the output image ‘g’ at those coordinates is equal to the result
of applying T to the neighborhood with origin at (x, y) in f.
For example, if the neighborhood is a square of size 3x3, and that operator
T is defined to compute the average intensity of the neighborhood. Consider an
arbitrary location in an image, say (100,150). Assuming that the origin of the
neighborhood is at its center, the result, g (100, 150), at that location is computed
as the sum of f (100, 150) and its 8-neighbors, divided by 9 (i.e., the average
intensity of the pixels encompassed by the neighborhood). The origin of the
neighborhood is then moved to the next location and the procedure is repeated to
generate the next value of the output image g. Typically, the process starts at the
top left of the input image and proceeds pixel by pixel in a horizontal scan, one
row at a time. When the origin of the neighborhood is at the border of the image,
part of the neighborhood will reside outside the image.
The procedure is either to ignore the outside neighbors in the computations
specified by T, or to pad the image with a border of 0s or some other specified
intensity values. The thickness of the padded border depends on the size of the
neighborhood. This whole process is called as spatial filtering, in which the
neighborhood, along with a predefined operation, is called a spatial filter (also
referred as a spatial mask, kernel, template, or window). The type of operation
performed on the neighborhood determines the nature of the filtering process/1/.
114
4.2 Fundamentals of spatial filtering
The filtering is a fundamental operation in image processing. It can be used
for image enhancement, noise reduction, edge detection, and sharpening. The
concept of filtering has been applied in the frequency domain, where it rejects
some frequency components while accepting others. In spatial domain, filtering is
a pixel neighborhood operation. The commonly used spatial filtering techniques
include median filtering, average filtering, Gaussian filtering, etc. The filtering
function sometimes called filter mask, or filter kernel. They can be broadly
classified into two different categories: linear filtering and order-static filters. In
the case of linear filtering, the operation can be accomplished by convolution, i.e.,
the value of any given pixel in the output image is represented by the weighted
sum of the pixel values of its neighborhood (a linear combination) in the input
image.
For order-static filter, the value of a given pixel in the output image is
represented by some statistics within its support neighborhood in the original
image, such as the median filter. Those filters are normally non-linear and cannot
be easily implemented in the frequency domain. However, the common elements
of a filter are: (1) A neighborhood (2) An operation on the neighborhood
including the pixel itself. Typically the neighborhood is a rectangular of different
size, for example it may be 3x3, 5x5…. and smaller than the image itself /1,2/.
115
4.2.1 The mechanics of spatial filtering
The spatial filters as explained in the previous section, consists of a
neighborhood, and a predefined operation that is performed on the image pixels
encompassed by the neighborhood. Filtering creates a new pixel with coordinates
equal to the coordinates of the center of the neighborhood, and whose value is the
result of the filtering operation.
A processed (filtered) image is generated, as the center of the filter visits
each pixel in the input image. If the operation performed is on the image pixels is
linear, then the filter is said to be linear spatial filter. Otherwise, the filter is
nonlinear.
4.2.2 Spatial correlation and convolution
There are two closely related concepts for performing linear spatial
filtering. One is the correlation and the other is the convolution. Correlation is the
process of moving a filter mask over the image and computing the sum of
products at each location. The mechanics of the convolution are the same, except
that the filter is rotated by 180 degrees.
4.2.3 Generating spatial filter masks
Generating an m x n linear spatial filter requires specifying mn mask
coefficients. For example, to replace the pixels in an image by the average
116
intensity of 3 x 3 neighborhood centered on those pixels, the average value at any
location (x, y) in the image is determined by the sum of the nine intensity values
in the 3 x 3 neighborhood centered on (x, y) divided by 9.
Letting zi = 1,2,…….9, denote these intensities, the average is
9
19
1
iiZR (4.2)
This linear filtering operation with 3 x 3 mask whose coefficients are 1/9
implements the desired averaging. This operation results in image smoothing /1/
4.3 Smoothing spatial filters
The smoothing filters are used for blurring and for noise reduction.
Blurring is used in preprocessing steps, such as removal of small details from an
image prior to (large) object extraction, and bridging of small gaps in lines or
curves. Noise reduction can be accomplished by blurring with a linear and also by
non-linear filtering.
4.3.1 Smoothing Linear Filters
The output of a smoothing, linear spatial filter is simply the average of the
pixels contained in the neighborhood of the filter mask. These filters sometimes
are called averaging filters and they are also referred as low-pass filters. The idea
behind smoothing filters is straightforward. By replacing the value of every pixel
117
in an image by the average of the fray levels in the neighborhood defined by the
filter mask. This process results in an image with reduced ‘sharp’ transitions in
gray levels. The most obvious application of smoothing is noise reduction.
However, edges (which almost always are desirable features of an image) also are
characterized by sharp transitions in gray levels, so averaging filters have the
undesirable side effect that they blur edges.
The another application of this type of process includes the smoothing of
false contours that result from using an in sufficient number of gray levels. A
major use of averaging filters is in the reduction of ‘irrelevant’ detail in an image.
By ‘irrelevant’ pixel means pixel regions that are small with respect to the size of
the filter mask/1/.
4.3.2 Order-static (non-linear) filters
The order-static filters are nonlinear spatial filters whose response is based
on ordering (ranking) the pixels contained in the image area encompassed by the
filter, and then replacing the value of the center pixel with the value determined
by the ranking result. The best-known example in this category is the median
filter, which as its name implies, replaces the value of a pixel by the median of the
gray levels in the neighborhood of that pixel ( the original value of the pixel is
included in the computation of the median ).
118
4.3.3 Median Filter
The median filters are quite popular because, for certain types of random
noise, it has excellent noise-reduction capabilities, with considerably less blurring
than linear smoothing filters of similar size. These filters are particularly effective
in the presence of impulse noise, also called salt-and-pepper noise because of its
appearance as white and black dots superimposed on an image.
The median M, of a set of values is such that half the values in the set are
less than or equal to M, and half are greater than or equal to M. in order to perform
median filtering at a point in an image. First sort the values of the pixel in
question and its neighbors, determine their median, and assign this value to that
pixel. For example, in a 3 x 3 neighborhood the median is the 5th largest value, in
a 5 x 5 neighborhood the 13th largest value, and so on. When several values in a
neighborhood are the same, all equal values are grouped.
For example, a 3 x 3 neighborhood has values (10, 20, 20, 20, 15, 20, and
25,100).These values are sorted as (10,15,20,20,20,20,20,25,100), which results in
a median of 20. Thus, the principal function of median filters is to force points
with distinct gray levels to be more like their neighbors. In fact, isolated clusters
of pixels that are light or dark with respect to their neighbors, and whose area is
less than n2/2 (one-half the filter area), are eliminated by an n x n median filter. In
this case ‘eliminated’ means forced to the median intensity of the neighbors/1/.
The median is calculated by first sorting all the pixel values from the
surrounding neighborhood into numerical order and then replacing the pixel being
119
considered with the middle pixel value. The median filter, especially with larger
window size destroys the fine image details due to its rank ordering process.
Figure 1.Illustrates an example calculation of median value. The central pixel
value of 150 is rather unrepresentative of the surrounding pixels and is replaced
with the median value: 124
Neighborhood values: 115,119,120,123,124,125,126,127,150
Median value: 124
Figure 4.2: Calculating the median value of a 3x3 pixel neighborhood.
4.3.4 Max and min filters
Although the median filter is by far the order-static filter used in image
processing, it is by no means the only one. The median represents the 50th
percentile of a ranked set of numbers, but from basics of statistics the ranking
lends itself to many other possibilities. For example, using the 100th percentile
results in the so called max filter, this filter is useful for finding the brightest
110 125 125 130 140
123 124 126 127 136
114 120 150 125 134
118 115 119 123 134
111 116 111 120 131
120
points in an image. Also because the pepper noise has very low values, it is
reduced by this filter as a result of the max selection process in the sub image
areaThe 0th percentile filter is known as the min filter. This filter is useful in
finding the darkest points in an image and also, it reduces salt noise as a result of
the min operation.
4.3.5 Midpoint filter
The midpoint filter simply computes the midpoint between the maximum
and minimum values in the area encompassed by the filter. The filter combines
the order statics and averaging. It works best for randomly distributed noise, like
Gaussian noise or uniform noise.
4.3.6 Mean Filtering
The mean filtering is a simple and easy to implement method for
smoothing images, i.e. it reduces the amount of intensity variation between one
pixel and the next. It is often used to reduce noise in images The idea of mean
filtering is simply to replace each pixel value in an image with the mean value of
its neighbors, including itself.
A 3×3 mean filter is used for smoothing the image containing the salt and
pepper noise. Since the shot noise pixel values are often very different from the
surrounding values, they tend to significantly distort the pixel average calculated
by the mean filter /1/.
121
4.4 Modern image denoising methods
Consider an image that has been blurred and contaminated by salt and
pepper noise. Typical sources of blur are defocus and motion of camera/3/. Salt
and pepper noise is a common model for the effects of bit errors in transmission,
malfunctioning pixels and faulty memory locations/4/.
Significant attention has been given to image denoising in the presence of
Gaussian noise /3/. We focus on various methods that have an important role in
modern image denoising research /5-8/. Most methods rely on the standard model
nfhg * , that is applicable to a large variety of image degradation processes
that are encountered in practice. Here ‘h’ represents a known space-invariant blur
kernel (point spread function), ‘f’ is an ideal version of the observed image ‘g’
and ‘n’ is (usually Gaussian) noise. In this research,the focus is on the case of salt
and pepper noise.
The assumption of Gaussian noise is a fundamental element of common
image denoising algorithms. It is therefore not surprising that those algorithms
produce inadequate results in the presence of salt and pepper noise. This fact is
illustrated in figure4.3. The top-left image in figure 4.3 is the 256x256 Lena
image, blurred by a pill-box kernel of radius 3 and contaminated by Gaussian
noise.
Excellent restoration is obtained using the state of the art denoising method
of /7/ (top-right). The bottom-left image in figure 4.3 is the same blurred Lena
image, is contaminated by salt and pepper noise of density 0.01. In this case
122
restoration using the method of /7/ is clearly inadequate (bottom-right). Note that
due to the inadequacy of the noise model, the algorithm of /7/ yields poor results
even at lower salt and pepper noise density.
A variety of filtering techniques have been proposed for enhancing images
degraded by salt and pepper noise. The classical linear digital image filters, such
as averaging low pass filters, tend to blur edges and other fine image details.
Therefore, nonlinear filters /15, 16/ are most preferred over linear filters due to
their improved filtering performance in terms of noise suppression and edge
preservation.
Figure 4.3: Top-left: Blurred image with Gaussian noise. Top-right: Restoration using the method of /23/. Bottom-left: Blurred image with salt and pepper noise. Bottom-right: Restoration using the method of /23/.
123
The standard median (SM) filter /17/ is the one of the most robust
nonlinear filters, which exploits the rank-order information of pixel intensities
within filtering window. This filter is very popular due to its edge preserving
characteristics and its simplicity in implementation. Various modifications of the
SM filter have been introduced, such as the weighted median (WM) /18/ filter. By
incorporating noise detection mechanism into the conventional median filtering
approach, the filters like switching median filters /19,20/ had shown significant
performance improvement. Salt and pepper noise removal is considered in the
literature by itself. It is commonly approached using median-type filters /9-11/.
Recently, a promising variational method for impulse denoising was proposed by
/12-14/. At high noise density, image denoising using median type filtering
creates distortion that depends on the neighborhood size.
The median filter, as well as its modifications and generalizations /21/ is
typically implemented invariably across an image. Examples include the mimum-
maximumum exclusive mean filter (MMEM) /22/, Florencio’s /23/, Adaptive
median filter(AMF) /24/. These filters have demonstrated excellent performance
but the main drawbacks of all these filters are, they are prone to edge jitters in the
cases where noise density is high and their large widow size results in blurred
images and significant computational complexity. To overcome this problem, a
modified median filter algorithm called Interpolate Median filter that employs
Interpolated search in determining the desired central pixel value is proposed.
124
4.5 Interpolate median filter
In this section a new approach to image denoising called Interpolate
Median Filter (IMF) is proposed. The Interpolate Median filter method considers
each pixel in the image in turn and looks at its neighbors to decide whether or not
it is representative of its surroundings. Instead of replacing the pixel value with
the median of neighboring pixel values, it replaces it with the interpolation of
those values. The interpolation is calculated by first sorting all pixel values from
surrounding neighborhood into numerical order and then replacing the pixel being
considered with the interpolation pixel value. The calculation of interpolation
value is derived from the Interpolation search technique used for searching the
elements. We can also call it a Non- linear filter or order-static filter because there
response is based on the ordering or ranking of the pixels contained within the
mask.
The advantages of this filter over mean and median filter are, it gives more
robust average than both the methods, for some pixels in the neighborhood; it
creates new pixel values like mean filter and for some it will not create new pixel
value like median filter, It has the characteristics of both filters. The algorithm
uses the following relations:
2/])[][( halaK , (4.3)
where K is the ‘key’, Here we make an intelligent guess about ‘key’ which is the
mid value of the array ‘a’, and ][],[ hala are values of bottom and top elements in
the sorted array.
125
The value of the ‘key’ K is used in the relation 4.4 to determine the interpolated
value
]))[][((*)( lahaklhlMid . (4.4)
Here value ‘Mid’ gives the optimal mid-point of the array and a[mid] gives the
interpolated value. This interpolated value is the new value of the pixel.
4.5.1 Implementation of Interpolate median filter
The steps of implementing Interpolate Median filter is given followed by
the corresponding flowchart in figure 4.4.
Step 1:
Read the original standard image (Lena.png, Barbara.png,Goldhill.png).
Step 2:
The preprocessing of image is done which resizes the loaded image to a
standard size of 512 x 512, suitable for further processing.
Step 3:
The noise is added to the standard test images. In this work Salt & pepper
noise is used as it is the simplest type of noise among all. According to a given
density D more or less pixels are flipped randomly to black (0) or white (1). D is
just measure of the amount of noise to be added, not a value! This type of noise is
also independent of the image it is added to.
126
Step 4:
The noisy image is then subjected to Interpolate Median Filtering. The
resultant image is the denoised image.
Step 5:
The peak signal to noise ratio (PSNR) is calculated for all the standard
images with their noisy and denoised counterparts, respectively. The PSNR values
are compared with some traditional standard methods.
4.5.2 Flowchart for the Interpolate median filter
Figure 4.4 Flow chart for Interpolate median filter
127
4.5.3 Matlab code for the Interpolate median filter
% READ THE IMAGE
img1=imread('lena.png');figure,imshow(img1)img2 = imnoise(img1,'salt & pepper',0.5);figure,imshow(img2)img2=double(img2);[Height,width]=size(img2);img = zeros(width,Height);for ycoord=1:1:Height; topbound=ycoord-1; bottombound=ycoord+1; if topbound<1 topbound=1;end if bottombound>Height; bottombound=Height; endfor xcoord=1:1:width; leftbound=xcoord-1; rightbound=xcoord+1; if leftbound<1 leftbound=1; end if rightbound>width rightbound=width; endarrsize = (rightbound-leftbound+1)*(bottombound-topbound+1); arr2 = zeros(arrsize,1); xindex=leftbound; yindex=topbound; index=1;while index<=arrsize arr2(index)=img2(xindex,yindex); xindex=xindex+1; if xindex >rightbound; xindex=leftbound; yindex=yindex+1;end if yindex>bottombound;
128
break;end index=index+1;end
% SORTING OF ARRARY TO FIND INTERPOLATED MEDIANsortedarr = SelectionSort(arr2);a=sortedarr;low=1;l=length(a);high=l;m=ceil((low+high)/2);key=a(m); if (a(high)-a(low)==0) w=0.1+a(high)-a(low); else w=a(high)-a(low); end z=ceil(u*v/w);if ( z==0) z=ceil(low+high)/2);end img(xcoord,ycoord,1)= a(z);%mid; %img(xcoord,ycoord,1)=sortedarr(ceil((arrsize)/2)); endend
img=uint8(img);figure,imshow(img)img=double(img);%img2=uint8(img2);%snr=20*log10(norm(img2))/norm(img2-img)% FINDING SIGNAL TO NOISE RATION = prod(size(img1));img1= double(img1(:)); img = double(img(:));t1 = sum((img1-img).^2); t2 = sum(img1.^2);MSE = t1/NPSNR = 10*log10(255*255/MSE)
129
4.7 Simulation results
The proposed method is tested on some natural grayscale test images like
Lena, Barbara and Goldhill of size 512*512 pixel, at different noise levels. Table
4.1, illustrates the comparison of PSNRs of the six denoising methods. The PSNR
(in dB) is calculated using the formula defined by
)(255
log102
dBMSE
PSNR (3.23)
with 21
0
1
0
),(),(1
m
i
n
j
jiKjiImn
MSE , (3.24)
where I and K being the original image and de-noised image, respectively.
The original image and the noisy image of Lena is shown in th fig. 4.5
Figure 4.5 (a): The original test image (Lena) with 512x512 pixels
Figure 4.5 (b): Lena image corrupted by salt & pepper noise(dB) (20%)
130
The performance analysis of the method for Lena and Barbara image is given in
table 4.2, the noise density is varied fron 10% to 50% in steps of 10 and PSNR
values are tabulated.
TABLE 4. 1.
PSNR Performance of Different Algorithms for Lena image corrupted with salt and pepper noise
AlgorithmNoise Density in dB
10% 20% 30%
MF(3x3) 31.19 28.48 25.45
MF(5x5) 29.45 28.91 28.43
MMEM [8] 30.28 29.63 29.05
Florencio’s [9] 33.69 32.20 30.95
AMF(5x5) [10] 30.11 28.72 27.84
IMF(Proposed) 33.86 30.59 25.75
TABLE 4.2
Performance analysis
Noise Density in dB (in %)
Lena Barbara
10 33.86 24.83
20 30.59 23.82
30 25.75 21.80
40 20.02 19.00
50 17.23 16.08
131
4.7 Conclusions
The proposed algorithm called Interpolate Median filter employs
Interpolated search in determining the desired central pixel value. Interpolation
median filter for image denoising is a simple method and easy to implement.
The simulation results show that the proposed method performs
significantly better than many other existing methods
References
/1/ Rafael C. Gonzalez, Richard E. Woods and Steven L. Eddins. Digital
Image
Processing Using MATLAB. Pearson Education (Singapore) Pvt. Ltd.,
Indian
Branch, 482 F.I.E. Patparganj, Delhi 110092, India (2004).
/2/ A. K. Jain. Fundamentals of digital image processing. Prentice-Hall
(1989).
/3/ M. Banham and A. Katsaggelos. Digital Image Restoration. IEEE Signal
Pro-cessing Mag., 14, pp. 24-41 (1997).
/4/ G.R. Arce, J.L. Paredes and J. Mullan. Nonlinear Filtering for Image
Analysis and Enhancement. in A.L. Bovik (Ed.), Handbook of Image &
Video Processing, Academic Press (2000).
/5/ L. Rudin, S. Osher and E. Fatemi. Non Linear Total Variation Based Noise
Re-moval Algorithms. Physica D, 60, pp. 259-268 (1992).
/6/ L. Rudin and S. Osher. Total Variation Based Image Restoration with Free
Local Constraints. Proc. IEEE ICIP, 1, pp. 31-35, Austin TX, USA (1994).
/7/ C. Vogel and M. Oman. Fast, Robust Total Variation-based Reconstruction
of Noisy, Blurred Images. IEEE Trans. Image Processing, 7, pp. 813-824,
(1998).
132
/8/ J. Bect, L. Blanc-Feraud, G. Aubert and A. Chambolle. A l1-Uni ed
Variational Framework for Image Restoration. Proc. ECCV'2004, Prague,
Czech Republic, Part IV: LNCS #3024, pp. 1-13, Springer (2004).
/9/ T. Chen and H.R. Wu. Space Variant Median Filters for the Restoration of
Impulse Noise Corrupted Images. IEEE Trans. Circuits and Systems II, 48,
pp. 784-789 (2001).
/10/ H. Hwang and R. A. Haddad. Adaptive Median Filters: New Algorithms
and Results. IEEE Trans. Image Processing, 4, pp. 499-502 (1995).
/11/ G. Pok, J.-C. Liu and A.S. Nair. Selective Removal of Impulse Noise based
on Homogeneity Level Information. IEEE Trans. Image Processing, 12,
pp. 85-92 (2003).
/12/ R.H. Chan, C. Ho and M. Nikolova. Salt-and-Pepper Noise Removal by
Median-type Noise Detectors and Detail-preserving Regularization. IEEE
Trans., 14 pp 1479-1485 (2005).
/13/ M.Nikolova. Minimizers of Cost-Functions Involving Nonsmooth Data-
Fidelity Terms: Application to the Processing of Outliers. SIAM Journal
on Numerical Analysis, 40, pp. 965-994 (2002).
/14/ M. Nikolova. A Variational Approach to Remove Outliers and
Impulse Noise. Journal of Mathematical Imaging and Vision, 20, pp.
99-120, (2004).
/15/ R. Boyleand, R. Thomas. Computer Vision:A First Course, Blackwell
Scientific Publications, pp 32 – 34 (1988).
/16/ E. Davies. Machine Vision: Theory, Algorithms and Practicalities,
Academic Press, Chap. 3 (1990).
/17/ I. Pitas and A. N. Venetsanopoulos .Order statistics in digital image
processing. Proc. IEEE, 80, no. 12, pp. 1893–1921 (1992).
/18/ D. R. K. Brownrigg. The weighted median filter. Commun. ACM, 27,
no. 8, pp. 807–818 (1984).
133
/19/ H. Hwang and R. A. Haddad. Adaptive median filters: New algorithms
and results. IEEE Trans. Image Process., 4, no. 4, pp.499–502 (1995).
/20/ A. Bovik, Handbook of Image & Video Processing. 1st Ed. New York:
Academic (2000).
/21/ http://homepages.inf.ed.ac.uk
/22/ W. Y. Han and J. C. Lin. Minimum–maximum exclusive mean
(MMEM) filter to remove impulse noise from highly corrupted
images. Electron. Lett., 33, no. 2, pp. 124-125 (1997).
/23/ T. Sun and Y. Neuvo. Detail-preserving median based filters in image
processing. Pattern Recognit. Lett., 15, no. 4, pp. 341–347 (1994).
/24/ A. Sawant, H. Zeman, D. Muratore, S. Samant, and F. DiBianka. An
adaptive median filter algorithm to remove impulse noise in X-ray and
CT images and speckle in ultrasound images. Proc.SPIE 3661,pp.
1263–1274, Feb. (1999).