digitalimageprocessing11-imagerestoration1
TRANSCRIPT
Course Website: http://www.comp.dit.ie/bmacnamee
Digital Image Processing
Image Restoration:
Noise Removal
2of58
Contents
In this lecture we will look at image restoration techniques used for noise removal
– What is image restoration?– Noise and images– Noise models– Noise removal using spatial domain filtering
3of58
What is Image Restoration?
Image restoration attempts to restore images that have been degraded
– Identify the degradation process and attempt to reverse it
– Similar to image enhancement, but more objective
4of58
“Better” visual representation
Subjective
No quantitative measures
Remove effects of sensing environment
Objective
Mathematical, model dependent quantitative measures
What is Image Restoration?Enhancement vs. Restoration
Enhancement Restoration
5of58
Enhancement Restoration
SpatialDomain
FrequencyDomain
Point Processing• >>imadjust• >>histeq
Spatial filtering• >>filter2
Filtering• >>fft2/ifft2• >>fftshift
• Inverse filtering• Wiener filtering
Image Preprocessing
What is Image Restoration?
Spatial filtering• >>filter2
SpatialDomain
FrequencyDomain
6of58
Image Restoration General
One has to have some a priori knowledge about the degragation process.
Usually we need to know:The noise in the original imageModel for degragationSome information from original image
7of58
A Model of Image Degradation and Restoration
),( ),(*),(),( yxyxfyxhyxg
),( ),(),(),(G vuNvuFvuHvu
The degradation process is modeled as a degradation function that together with an additive noise term.
In frequency domain representation:
Where: f(x,y) is the input image, g(x,y) is the degraded image, h(x,y) is the degradation function, and is the additive noise.),( yx
8of58
Degradation Model
f(x,y) h(x,y) g(x,y)
n(x,y)
Degradation Model: g = h*f + n
9of58
Restoration Model
f(x,y) DegradationModel
f(x,y)RestorationFilter
Unconstrained Constrained• Inverse Filter• Pseudo-inverse Filter
• Wiener Filter
10of58
Restoration Model
The objective of restoration is to obtain an estimate of the original image f(x,y).
Generally, the more we know about H, and , the closer will be to f(x,y).
The approach used throughout most of this chapter is based on various types of image restoration filters.
),( yxf
),( yxf
11of58
Noise and Images
The sources of noise in digital images arise during image acquisition (digitization) and transmission
– Imaging sensors can be affected by ambient conditions
– Interference can be added to an image during transmission
12of58
Noise Models
There are many different models for the image noise term η(x, y):
– Gaussian• Most common model
– Rayleigh– Erlang– Exponential– Uniform– Impulse
• Salt and pepper noise
13of58
Noise Models
22 2/)(
2
1)(
zezp
Gaussian noise:
4
)4(;4/
)(
2
)(2
0
/2)(
bba
zpazforeaz
b
azfor
baz
=
Rayleigh noise:
14of58
Noise Models
22
0!1
00
/;/
)(
1
abab
zpzfore
b
za
zfor
azbb
=
)-(
Erlang (Gamma) noise:
22
0
00
/1;/1
)(
aa
zp zforae
zfor
az
=
Exponential noise:
15of58
Noise Models
12/)(;2/)(
)(
22
1
0
abba
zpbzaif
ab
otherwise
=
)-(
Uniform noise:
otherwise
bzforp
azforp
zp b
a
0
)(
Impulse noise:
16of58
For pa=pb=0.05 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
Input image
128 128 255 0 128 128 128 128 128 128 128 128 128 128 0 128 128 128 128 0 128 128 128 128 128 128 128 128 128 128 128 128 0 128 128 128 128 128 128 128 128 128 128 255 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 0 128 128 128 128 255 128 128 128 128 128 128 128 128 128 128 128 128 128 255 128 128 128 128 128 128 128 255 128 128
Degraded image
Noise level p=0.05 means that approximately 5% of pixels are contaminated by salt or pepper noise (highlighted by red color)
Noise Models
Impulse noise is also called salt-and-pepper noise.
17of58
MATLAB Command
>Y = IMNOISE(X,'salt & pepper',p)
Notes:
The intensity of input images is assumed to be normalized to [0,1]. If X is not double, you need to do normalization first, i.e., X=X/255; If X is uint8, MATLAB would do the normalization automatically
The default value of p is 0.05 (i.e., 5 percent of pixels are contaminated)
Imnoise function can produce other types of noise as well (you need to change the noise type ‘salt & pepper’)
Example: impulsenoise.m
18of58
Noise Models
Remarks: The preceding PDFs provide useful tools for modeling a
broad range of noise corruption situations in practice. Gaussian noise arises due to factors such as electronic
circuit noise and sensor noise caused by poor illumination and/or high temperature.
Rayleigh is helpful in characterizing noise phenomena in range imaging.
Exponential and gamma find application in laser imaging. Impuse noise is found in situations where quick transients,
such as faulty switching. Uniform is the least descriptive of practical situations.
However, it is quite useful in simulations.
19of58
Noise Example
The test pattern to the right is ideal for demonstrating the addition of noise
The following slides will show the result of adding noise based on various models to this image
Histogram to go here
Image
Histogram
20of58
Noise Example (cont…)
Gaussian Rayleigh Erlang
21of58
Noise Example (cont…)
Exponential Uniform Impulse
22of58
Periodic Noise
Periodic noise in an image arises typically from electrical or electromechanical interference during image acquisition.
Characteristics– Spatially dependent– Periodic – easy to observe in frequency
domain
Processing method– Suppressing noise component in frequency
domain
23of58
Periodic Noise
spatial Frequency (note the four pairs of bright dots)
See Table 4-1:
24of58
Estimation of Noise Parameters
Periodic noise typically are estimated by inspection of the Fourier spectrum of the image.
The parameters of noise PDFs may be known from sensor specifications.
It is often necessary to estimate them for a particular imaging device.
When images generated by the sensor are available, frequently it is possible to estimate the parameters of the PDF from small patches of constant gray level.
25of58
Estimation of Noise Parameters
Gaussian noise Rayleigh noise Uniform noise
26of58
Estimation of Noise Parameters
2 2
( )
( ) ( )
i
i
i iz S
i iz S
z p z
z p z
The simplest way to use the data from the image strip is for calculating the mean and variance of the gray levels.
Where zi is the gray level values of the pixels in S, and p(zi) are the corresponding normalized histogram values.
27of58
Estimation of Noise Parameters
If the shape is approximately Gaussian, then the mean and variance is all we need. Because Gaussian PDF is completely specified by these two parameters.
22 2/)(
2
1)(
zezp
28of58
Estimation of Noise Parameters
For the other shapes discussed before, we can use the mean and variance to calculate the parameters a and b. For example, Rayleigh noise:
For impulse noise we can estimate the probability of occurrence of white and black pixels. So, a midgray, relatively constant area is needed.
4
)4(;4/
)(
2
)(2
0
/2)(
bba
zpazforeaz
b
azfor
baz
=
29of58
Restoration of Noise Only Degradation
We can consider a noisy image to be modelled as follows:
where f(x, y) is the original image pixel, η(x, y) is the noise term and g(x, y) is the resulting noisy pixel
),(),(),(
),( ),(),(
vuNvuFvuG
yxyxfyxg
30of58
If the noise is known, we can just subtract them from g(x,y) or G(u,v) to restore f(x,y) or F(u,v).
Usually, the noise is unknown, so subtracting them from g(x,y) or G(u,v) is not a realistic option.
In the case of periodic noise, it is possible to estimate N(u,v) from the spectrum of G(u,v), then N(u,v) can be subtracted from G(u,v) to obtain an estimate of the original image.
However, this type of knowledge is the exception, rather than the rule.
When only additive noise is present, spatial filtering is a choice. In this case, enhancement and restoration become almost the same.
Restoration of Noise Only Degradation
31of58
Mean filters
We can use different kinds of spatial filters to remove different kinds of noise
The arithmetic mean filter is a very simple one and is calculated as follows:
This is implemented as the simple smoothing filter
Blurs the image to remove noise
xySts
tsgmn
yxf),(
),(1
),(ˆ
1/91/9
1/9
1/91/9
1/9
1/91/9
1/9
32of58
Other Means
There are different kinds of mean filters all of which exhibit slightly different behaviour:
– Geometric Mean– Harmonic Mean– Contraharmonic Mean
33of58
Other Means (cont…)
There are other variants on the mean which can give different performance
Geometric Mean:
Achieves similar smoothing to the arithmetic mean, but tends to lose less image detail
mn
Sts xy
tsgyxf
1
),(
),(),(ˆ
34of58
Mean Filters
OriginalImage
ImageCorrupted By Gaussian Noise
After A 3*3Geometric Mean Filter
After A 3*3Arithmetic
Mean Filter
Example: meanfilter.m
35of58
Other Means (cont…)
Harmonic Mean:
Works well for salt noise, but fails for pepper noise
Also does well for other kinds of noise such as Gaussian noise
xySts tsg
mnyxf
),( ),(1
),(ˆ
36of58
Other Means (cont…)
Contraharmonic Mean:
Q is the order of the filter and adjusting its value changes the filter’s behaviourPositive values of Q eliminate pepper noiseNegative values of Q eliminate salt noiseQ=0 Reduced to arithmetic mean filterQ=-1Reduced to the harmonic mean filter
xy
xy
Sts
Q
Sts
Q
tsg
tsg
yxf
),(
),(
1
),(
),(
),(ˆ
37of58
Mean Filters(cont…)
ImageCorruptedBy Pepper
Noise
Result of Filtering Above
With 3*3 Contraharmonic
Q=1.5
Blurred the dark area, and cleared the background
38of58
Mean Filters(cont…)
ImageCorruptedBy SaltNoise
Result of Filtering Above With 3*3 ContraharmonicQ=-1.5
Blurred the background, and cleared the dark area
39of58
Mean Filters(cont…)
Choosing the wrong value for Q when using contraharmonic mean filter can have drastic results
Q=-1.5 Q=1.5
40of58
Mean Filters(cont…)
Arithmetic and Geometric mean filters Random noise: Gaussian or uniform noise
Harmonic mean filter Salt noise, not good for pepper noise Gaussian noise
Contraharmonic mean filter Impulse noise Prior knowledge about the noise is dark or
light
41of58
Order Statistics Filters
Spatial filters that are based on ordering the pixel values that make up the neighbourhood operated on by the filter
Useful spatial filters include– Median filter– Max and min filter– Midpoint filter– Alpha trimmed mean filter
42of58
Median Filter
Median Filter:
Excellent at noise removal, without the smoothing effects that can occur with other smoothing filters
Particularly good when salt and pepper noise is present
)},({),(ˆ),(
tsgmedianyxfxySts
43of58
ImageCorrupted
By Salt AndPepper Noise
Pa=Pb=0.1
Result of 1 Pass With A 3*3 MedianFilter
Result of 2Passes With
A 3*3 MedianFilter
Result of 3 Passes WithA 3*3 MedianFilter
Example: medianfilter1.m
Median Filter
44of58
Note:It is a good example of the power of median filtering in
handling impulse additive noise.Repeat passes of a median filter tend to blur the image.It is desirable to keep the number of passes as low as
possible.
Median Filter
45of58
Max and Min Filter
Max Filter:
Min Filter:
Max filter is good for pepper noise and min is good for salt noise
)},({max),(ˆ),(
tsgyxfxySts
)},({min),(ˆ),(
tsgyxfxySts
46of58
Noise Removal Examples (cont…)
ImageCorruptedBy Pepper
Noise
ImageCorruptedBy SaltNoise
Result Of Filtering Above With A 3*3 Min Filter
Result OfFiltering
AboveWith A 3*3Max Filter
Example: maxminfilter.m
47of58
– For max filter, it will remove pepper noise, but it also removed some dark pixels from the borders of dark objects.
– The same as min filter, it will remove some white points around the border of light objects.
Noise Removal Examples (cont…)
48of58
Midpoint Filter
Midpoint Filter:
Good for Gaussian and random uniform noise
)},({min)},({max
2
1),(ˆ
),(),(tsgtsgyxf
xyxy StsSts
49of58
Alpha-Trimmed Mean Filter
Alpha-Trimmed Mean Filter:
We can delete the d/2 lowest and d/2 highest grey levels. So gr(s, t) represents the remaining mn – d pixels
d=0: the arithmetic mean filterd=(mn-1)/2: Median filterOther d: Multiple types of noise: Good for the combination of salt-and-pepper and Gaussian noise
xySts
r tsgdmn
yxf),(
),(1
),(ˆ
50of58
Noise Removal Examples (cont…)
ImageCorrupted
By UniformNoise
Image FurtherCorruptedBy Salt andPepper Noise
Filtered By5*5 Arithmetic
Mean Filter
Filtered By5*5 Median
Filter
Filtered By5*5 GeometricMean Filter
Filtered By5*5 Alpha-TrimmedMean Filter
51of58
Adaptive Filters
The filters discussed so far are applied to an entire image without any regard for how image characteristics vary from one point to anotherThe behaviour of adaptive filters changes depending on the characteristics of the image inside the filter region
An increase in filter complexityWe will take a look at the adaptive median filter
52of58
Adaptive Median Filtering
The median filter performs relatively well on impulse noise as long as the spatial density of the impulse noise is not large (Pa and Pb are less than 0.2)
The adaptive median filter can handle much more spatially dense impulse noise, and also performs some smoothing for non-impulse noise
An additional benefit of the adaptive median filter is that it seeks to preserve detail while smoothing nonimpulse noise.
The key insight in the adaptive median filter is that the filter size changes depending on the characteristics of the image
53of58
Adaptive Median Filtering (cont…)
Remember that filtering looks at each original pixel image in turn and generates a new filtered pixel
First examine the following notation:
– zmin = minimum grey level in Sxy
– zmax = maximum grey level in Sxy
– zmed = median of grey levels in Sxy
– zxy = grey level at coordinates (x, y)
– Smax =maximum allowed size of Sxy
54of58
Adaptive Median Filtering (cont…)
Level A: A1 = zmed – zmin
A2 = zmed – zmax
If A1 > 0 and A2 < 0, Go to level BElse increase the window size
If window size ≤ repeat Smax level A
Else output zmed
Level B: B1 = zxy – zmin
B2 = zxy – zmax
If B1 > 0 and B2 < 0, output zxy
Else output zmed
Zmed is an impulse?
Zxy is an impulse?
55of58
Adaptive Median Filtering (cont…)
The key to understanding the algorithm is to remember that the adaptive median filter has three purposes:
– Remove impulse noise– Provide smoothing of other noise– Reduce distortion, by not changing these
intermediate-level points. (excessive thinning or thickening of object boundaries)
56of58
Adaptive Filtering Example
Image corrupted by salt and pepper noise with
probabilities Pa = Pb=0.25
Result of filtering with a 7 * 7 median filter
Result of adaptive median filtering with smax
= 7
Choice of maximum allowed window size depends on the application. It should be increased as the density of the impulse increases.
A reasonable value can be estimated by experiment with various sizes of standard median filter.
57of58
Summary
In this lecture we looked at image restoration for noise removal
– Restoration is slightly more objective than enhancement
– Spatial domain techniques are particularly useful for removing random noise