6 Chapter3part2
6 Chapter3part2
IMAGE PROCESSING
CHAPTER 3: IMAGE ENHANCEMENT AND
RESTORATION (PART 2)
3
SHARPENING SPATIAL FILTERS
▪ Sharpening (i.e. high-pass filters):
➢ Highlight fine detail or enhance detail that has been
blurred
➢ The elements of the mask contain both positive and
negative weights
➢ Sum of the mask weights is 0
▪ Uses of image sharpening vary and include applications
ranging from electronic printing and medical imaging for
industrial inspection
4
DERIVATIVE OPERATOR
5
FIRST- AND SECOND-ORDER DIFFERENCE
OF 1D FUNCTION
▪ The basic definition of the first-order derivative of a one-
dimensional function f(x) is the difference of:
6
FIRST- AND SECOND-ORDER DERIVATIVE
OF 2D FUNCTION
▪ When we consider an image function of two variables,
f(x, y), at which time we will deal with partial
derivatives along the two spatial axes
7
LAPLACIAN FOR IMAGE ENHANCEMENT
8
LAPLACIAN FOR IMAGE ENHANCEMENT
9
10
EFFECT OF LAPLACIAN OPERATOR
11
THE EFFECT OF FEATURELESS
BACKGROUND CORRECTION
▪ This can be done effortlessly by adding the Laplacian image
to the original function
▪ However, one must be really careful with the Laplacian filter
used
12
13
RECAP OF FOURIER SERIES
▪ Any function that periodically repeats itself can be
expressed as a sum of sines and cosines of different
frequencies each multiplied by a different coefficient – a
Fourier series
14
THE DISCRETE FOURIER TRANSFORM
(DFT)
▪ The Discrete Fourier Transform of f(x, y), for x = 0, 1, 2,
…, M-1 and y = 0, 1, 2, …, N-1, denoted by F(u, v) is
given by the equation:
15
DFT & IMAGES
16
THE INVERSE DFT
17
THE DFT AND IMAGE PROCESSING
18
FREQUENCY DOMAIN FILTERING
FUNDAMENTALS
▪ Filtering in the frequency domain consists of modifying the
Fourier Transform of an image and then computing the inverse
transform to obtain the processed result
▪ Given a digital image, f(x, y) of size M x N, the basic
filtering equation in which we are interested has the form of:
19
FREQUENCY DOMAIN FILTERING
FUNDAMENTALS
▪ A filter H(u, v) that attenuates high frequencies while passing
low frequencies (appropriately called a lowpass filter) would
blur an image
▪ A filter with the opposite property (called a highpass filter)
would enhance edges detail (sharpening), but causes a
reduction in the image contrast
20
FREQUENCY DOMAIN FILTERING
FUNDAMENTALS
a = 0.850
22
IDEAL LOWPASS FILTERS
▪ A 2-D lowpass filter that passes (without attenuation) all
frequencies within a circle of radius D0 from the origin and
“cuts off” all frequencies outside this circle is called an ideal
lowpass filter (ILPF)
▪ It is specified by the function of:
25
IDEAL LOWPASS FILTERS
Result of Result of
filtering with filtering with
ideal low pass ideal low pass
filter of radius filter of radius
15 30
Result of Result of
filtering with filtering with
ideal low pass ideal low pass
filter of radius filter of radius
80 230
27
IDEAL LOWPASS FILTERS
▪ Filtering results in the previous slide denote the results of applying ILPFs
with cut-off frequencies at the radii with corresponding sizes
▪ The severe blurring in this image is a clear indication that most of the
sharp detail information in the picture is contained in the 13% power,
removed by the filter
▪ As the filter radius increases, less and less power is removed, resulting in
less blurring
▪ Note that the images in (c) through (e) are characterized by “ringing”,
which becomes finer in texture as the amount of high frequency content
removed decreases. Ringing is visible even in the image (e) in which only
2% of the total power was removed. This ringing behaviour is a
characteristic of ideal filters
▪ It is clear from this example that ideal lowpass filtering is not very
practical >> this image is quite close to the original
28
BUTTERWORTH LOWPASS FILTERS
30
Original Result of filtering
image with Butterworth
filter of order 2
and cutoff radius
5
31
BUTTERWORTH LOWPASS FILTERS
▪ Figure in previous slide shows the results of applying the BLPF
with n = 1 and D0
▪ Note that a smooth transition in blurring as a function of
increasing cut-off frequency
▪ And no ringing is visible in any of the images processed with
this particular BLPF, i.e. a fact attributed to the filter’s smooth
transition between low and high frequencies
▪ A BLPF of order 1 has no ringing in the spatial domain.
▪ Ringing generally is imperceptible in filters of order 2, but
can become significant in filters of higher order.
▪ BLPFs of order 2 are a good compromise between effective
lowpass filtering and acceptable ringing.
32
BUTTERWORTH LOWPASS FILTERS
33
GAUSSIAN LOWPASS FILTERS
▪ The transfer function of a Gaussian lowpass filter is defined
as:
34
GAUSSIAN LOWPASS FILTERS
35
Original image Result of filtering
with Gaussian
filter with cut-off
radius 5
36
GAUSSIAN LOWPASS FILTERS
▪ Figure in previous slide demonstrates: (a) Original image. (b)–(f) Results of
filtering using GLPFs with cut-off frequencies at the corresponding radii.
Compare with output figures of Ideal and Butterworth lowpass filters
▪ Notice that there is no ringing in the case of the GLPF
▪ This is an important characteristic in practice, especially in situations (e.g.,
medical imaging) in which any type of artefact is unacceptable
▪ In cases where tight control of the transition between low and high
frequencies about the cut-off frequency are needed, then the BLPF presents
a more suitable choice
▪ The price of this additional control over the filter profile is the possibility of
ringing
37
LOWPASS FILTERING
EXAMPLES/APPLICATIONS
A lowpass Gaussian filter is used to connect broken text
38
LOWPASS FILTERING
EXAMPLES/APPLICATIONS
Different lowpass Gaussian filters used to remove blemishes in
a photograph
39
LOWPASS FILTERING EXAMPLES
/APPLICATIONS
Original Gaussian
image lowpass filter
Spectrum
Processed
of original
image
image
40
IMAGE SHARPENING USING FREQUENCY
DOMAIN FILTERS
▪ Edges and other abrupt changes in intensities (fine detail in
images) are associated with high frequency components
➢ Image sharpening can be achieved in the frequency
domain by highpass filtering
▪ Highpass filters – only pass the high frequencies, attenuates
the low ones
▪ Highpass frequencies are precisely the reverse of lowpass
filters, therefore:
41
IDEAL HIGHPASS FILTERS
42
IDEAL HIGHPASS FILTERS
43
IDEAL HIGHPASS FILTERS
▪ Because of the way in
which they are related, it
can be expected for the
IHPFs to have the same
ringing properties as ILPFs
▪ Figure on the right shows
spatial representation of
an ideal frequency
domain highpass filters,
and its corresponding
intensity profiles through
their centers
44
IDEAL HIGHPASS FILTERS
Results of ideal high pass Results of ideal high pass Results of ideal high pass
filtering with D0 = 30 filtering with D0 = 60 filtering with D0 = 160 45
BUTTERWORTH HIGHPASS FILTERS
46
BUTTERWORTH HIGHPASS FILTERS
47
BUTTERWORTH HIGHPASS FILTERS
49
GAUSSIAN HIGHPASS FILTERS
52
IMAGE RESTORATION
▪ Goal: improve an image in some predefined sense
▪ Image enhancement: subjective process
▪ Image restoration: objective process
▪ Restoration attempts to reconstruct an image that has been
degraded by using a priori knowledge of the degradation
process
▪ Modeling the degradation and applying the inverse process to
recover the original image
▪ Image restoration also can be done in:
➢ Spatial domain; or
➢ Frequency domain
53
IMAGE RESTORATION
▪ Degradation of images can have many causes such as:
➢ Defects of optical lenses
➢ Nonlinearity of the electro-optical sensor
➢ Graininess of the film material
➢ Relative motion between an object and camera
➢ Wrong focus during image acquisition
➢ Atmospheric turbulence in remote sensing or astronomy
▪ The objective of image restoration is to reconstruct the original
image from its degraded version
➢ We consider the restoration problem only from the point where a
degraded, digital image is given
54
IMAGE RESTORATION (WITH RESPECT TO
SPATIAL AND FREQUENCY DOMAINS)
▪ We model the degradation process by a degradation function
h(x,y), an additive noise term (x,y), in the spatial domain as:
where:
➢ f(x,y) is the (input) image free from any degradation
➢ g(x,y) is the degraded image
➢ is the convolution operator
▪ The goal is to obtain an estimate of f(x,y) according to the
knowledge about the degradation function h and the additive
noise
▪ In frequency domain:
G ( u, v ) = H ( u, v ) F ( u, v ) + N ( u, v )
55
A MODEL OF DEGRADATION
56
NOISE MODELS
57
NOISE MODELS
▪ There are many different
models for the image noise
term η(x, y) - noise
probability density function:
▪ Gaussian
➢ Most common model
▪ Rayleigh
▪ Erlang (gamma)
▪ Exponential
▪ Uniform
▪ Impulse
➢ Salt and pepper noise
58
Original image
59
60
PERIODIC NOISE
▪ Arises typically from electrical
or electromechanical
interference during image
acquisition
▪ Provide variations to regular
noise patterns in an image
▪ Frequency domain techniques in
the form of Fourier
Transformation domain are the
most effective at removing
periodic noise
61
ESTIMATION OF NOISE PARAMETERS
▪ Periodic noise: inspection of the Fourier spectrum
▪ Others: try to compute the mean and variance of a
sub-image S (containing only constant gray levels)
62
RESTORATION IN THE PRESENCE OF NOISE
ONLY – SPATIAL FILTERING
▪ When the only degradation present in an image is noise, the
following equation:
becomes:
g ( x, y ) = f ( x, y ) + ( x, y )
▪ Spatial filtering is the method of choice in situations when
only additive noise is present
63
RESTORATION IN THE PRESENCE OF NOISE
ONLY – SPATIAL FILTERING
▪ Spatial filters of different kinds can be used to remove
different types of noise
▪ Mean filters for noise removal include:
➢ Arithmetic mean filter
➢ Geometric mean filter
➢ Harmonic mean filter
➢ Contraharmonic mean filter
64
RESTORATION IN THE PRESENCE OF NOISE
ONLY – SPATIAL FILTERING
▪ Arithmetic mean filters
➢ Simplest form of the mean filters
➢ Let Sxy represent the set coordinates in a rectangular sub-image
window of size m x n, centered at point (x, y)
➢ The arithmetic filtering process computes the average value of
the corrupted image g(x, y) in the area defined by Sxy
ˆf ( x, y) = 1
g ( s, t )
mn ( s ,t )S xy
▪ Implemented using convolution mask whereby all coefficients
have value 1/mn
▪ Noise is reduced as a result of blurring
➢ Mean filter smooths local variations in an image
65
RESTORATION IN THE PRESENCE OF NOISE
ONLY – SPATIAL FILTERING
▪ Geometric mean filter
➢ Each restored pixel is given by product of the pixels in the
sub-image window, raised to the power 1/mn
1
mn
fˆ ( x, y ) = g ( s, t )
( s ,t )S xy
➢ Smoothing results are comparable to the arithmetic mean
filter, but tends to lose less image detail in the process
66
67
RESTORATION IN THE PRESENCE OF NOISE
ONLY – SPATIAL FILTERING
▪ Harmonic mean filter:
➢ Works well for salt noise, but fails for pepper noise
➢ Does well also for other types of noise like Gaussian noise
➢ Noise filtering function of:
mn
fˆ ( x, y ) =
1
( s ,t )S xy g ( s, t )
68
RESTORATION IN THE PRESENCE OF NOISE
ONLY – SPATIAL FILTERING
▪ Contraharmonic mean filter:
➢ Yields a restored image based on the expression of:
g ( s ,
( s ,t )S xy
t ) Q +1
fˆ ( x, y ) =
g ( s ,
( s ,t )S xy
t ) Q
fˆ ( x, y ) = median{g ( s, t )}
( s ,t )S xy
75
76
RESTORATION IN THE PRESENCE OF NOISE
ONLY – SPATIAL FILTERING
▪ Midpoint filter
➢ Simply computes the midpoint between the maximum and
minimum values in the area encompassed by the filter
77
RESTORATION IN THE PRESENCE OF NOISE
ONLY – SPATIAL FILTERING
▪ Alpha-trimmed mean filter
➢ Suppose that we delete the d /2 lowest and the d /2
highest intensity values of in the neighbourhood Sxy
➢ Let gr(s, t) represent the remaining mn – d pixels
➢ A filter formed by averaging these remaining pixels is
called an alpha-trimmed mean filter where:
1
fˆ ( x, y ) = g r ( s, t )
mn − d ( s ,t )S xy
➢ When
❖ d = 0 : reduces to arithmetic mean filter
❖ d = mn -1 : reduces to median filter
78
79
PERIODIC NOISE REDUCTION BY FREQUENCY
DOMAIN FILTERING
▪ Tools for periodic noise reduction/removal include:
➢ Bandreject filters
❖ Ideal
❖ Butterworth
❖ Gaussian
➢ Bandpass filters
➢ Notch filters
▪ Bandreject filters
➢ Remove or attenuate a band of frequencies about the
origin of the Fourier transform
80
PERIODIC NOISE REDUCTION BY FREQUENCY
DOMAIN FILTERING
▪ Ideal bandreject filter is implemented via following function:
W
1 if D(u, v) D 0 −
2
W W
H (u , v) = 0 if D 0 − D(u, v) D 0 +
2 2
1 W
if D(u, v) D 0 +
2
▪ Butterworth bandreject filter of order n
1
H (u , v) = 2n
D(u , v)W
1+ 2 2
D (u , v) − D0
▪ Gaussian bandreject filter
2
1 D 2 ( u ,v ) − D02
−
2 D ( u ,v )W
H (u , v) = 1 − e 81
PERIODIC NOISE REDUCTION BY FREQUENCY
DOMAIN FILTERING
82
Use of bandreject filtering for periodic noise removal
83
PERIODIC NOISE REDUCTION BY FREQUENCY
DOMAIN FILTERING
▪ Bandpass filters
➢ Performs the opposite operation of a bandreject filter via:
H bp (u, v) = 1 − H br (u, v)
➢ Performing straight bandpass filtering on an image is not a
common procedure
❖ it generally removes too much image detail
➢ However, bandpass filtering is quite useful in isolating the
effects on an image caused by selected frequency bands
84
Example of bandpass filtering for extracting noise patterns
85
PERIODIC NOISE REDUCTION BY FREQUENCY
DOMAIN FILTERING
▪ Notch (reject) filters
➢ Rejects (or passes) frequencies in predefined neighbourhoods about a center
frequency
➢ Due to the symmetry of the Fourier Transform, notch filters must appear in
symmetric pairs about the origin, in order to obtain meaningful results
➢ The one exception to this rule is if the notch filter is located at the origin, in
which case it appears by itself
➢ The number of pairs of notch filters and the shape of the notch areas can be
arbitrary (one or more pairs; and rectangular or etc.)
➢ Transfer function of notch reject filters are given by:
𝐻NP (𝑢, 𝑣) = 1 − 𝐻NR (𝑢, 𝑣)
where 𝐻NP (𝑢, 𝑣) is the transfer function of the notch pass filter corresponding
to the notch reject filter of 𝐻N𝑅 (𝑢, 𝑣)
➢ Types of notch filters:
❖ Ideal notch filter
❖ Butterworth notch filter of order n
❖ Gaussian notch filter 86
PERIODIC NOISE REDUCTION BY FREQUENCY
DOMAIN FILTERING
87
ESTIMATING THE DEGRADATION FUNCTION
▪ 3 principal ways to estimate the degradation function for use in
image restoration:
➢ By image observation
❖ In order to reduce the effect of noise in our observation, we would
look for areas of strong signal content
➢ By experimentation
❖ Obtain the impulse response of the degradation by imaging an
impulse (small dot of light) using the same system settings
➢ By modeling
❖ Consider environmental conditions that cause degradations
✓ Physical characteristic of atmospheric turbulence (Hufnagel and
Stanley, 1964)
88
Image restoration – noise removal
http://bu.edu.eg/portal/uploads/Computers
%20and%20Informatics/Computer%20Scienc
e/838/crs-
6520/Files/Ch5_Image%20Restoration.pdf
89
THAT’S ALL!
END OF CHAPTER 3
(PART 2)