Professional Documents
Culture Documents
DIP4-Image Enahancement
DIP4-Image Enahancement
17-12-2021 DIP-SOCS-$P$ 1
IMAGE ENHANCEMENT
• Histogram Equalization modification and specification
• Spatial averaging
• Directional Smoothing
• Median
17-12-2021 DIP-SOCS-$P$ 2
IMAGE ENHANCEMENT-
Introduction
• Image enhancement is the procedure of improving the quality and
information content of original data before processing
17-12-2021 DIP-SOCS-$P$ 3
IMAGE ENHANCEMENT-
Introduction
• Image enhancement includes gray level and contrast manipulation, noise
reduction, edge crispening and sharpening, filtering, interpolation and
magnification, pseudocolouring, and so on
Image Enhancement
17-12-2021 DIP-SOCS-$P$ 6
IMAGE ENHANCEMENT-
Introduction
Image enhancement techniques can be divided into two broad categories:
Image Enhancement
17-12-2021 DIP-SOCS-$P$ 8
HISTOGRAM
17-12-2021 DIP-SOCS-$P$ 9
HISTOGRAM
• A histogram is a statistical representation of an image
• It doesn’t show any information about where the pixels are located in
the image. Therefore, two different images can have equivalent
histograms
For example, the two images here are different but have identical
histograms because both are 50% white (grayscale value of 255) and
50% black (grayscale value of 0)
17-12-2021 DIP-SOCS-$P$ 10
HISTOGRAM
• In image processing, a histogram shows the number of pixels (or voxels
in the case of a 3D image) for each intensity value in a given image
17-12-2021 DIP-SOCS-$P$ 11
HISTOGRAM
• The histogram of an image represents the relative frequency of
occurrence of the various gray levels in the image
17-12-2021 DIP-SOCS-$P$ 12
HISTOGRAM
17-12-2021 DIP-SOCS-$P$ 13
HISTOGRAM
Keep in Mind
17-12-2021 DIP-SOCS-$P$ 14
HISTOGRAM
• Histogram modelling has been found to be a powerful technique for
image enhancement
• Histogram Equalization
• Histogram Modification
• Histogram Specification
17-12-2021 DIP-SOCS-$P$ 15
HISTOGRAM
Modelling
• Histogram-modelling techniques modify an image so that its histogram has a
desired shape.
17-12-2021 DIP-SOCS-$P$ 16
HISTOGRAM
Modelling
• Histogram can be plotted in two ways:#1
X axis has gray levels & Y axis
has number of pixels in each
gray level
17-12-2021 DIP-SOCS-$P$ 17
HISTOGRAM
Modelling
• Histogram can be plotted in two ways:#2
P(μk) = nk / n
μk - gray level
nk - Number of pixels in kth gray level
n - Total number of pixels in an image
17-12-2021 DIP-SOCS-$P$ 18
HISTOGRAM EQUALIZATION
17-12-2021 DIP-SOCS-$P$ 19
Histogram Equalization
• In histogram equalization (also known as histogram flattening)
• The goal is to improve contrast in images that might be either blurry or have
a background and foreground that are either both bright or both dark
17-12-2021 DIP-SOCS-$P$ 20
Histogram Equalization
• Low contrast images typically have histograms that are concentrated within a tight range
of values
• Histogram equalization can improve the contrast in these images by spreading out the
histogram so that the intensity values are distributed uniformly over a larger intensity
range
17-12-2021 DIP-SOCS-$P$ 21
Histogram Equalization
The two images below are two examples of what the histogram for an input
image might look like before and after it goes through histogram equalization.
17-12-2021 DIP-SOCS-$P$ 22
Histogram Equalization
• Aims to obtain a uniform histogram for the output image
• Linear stretching is a good technique but not perfect since the shape remains the same
• Perfect image is one where all gray levels have equal number of pixels
• Here, our objective is not only to spread the dynamic range but also to have equal pixels at all
gray levels.
17-12-2021 DIP-SOCS-$P$ 23
Histogram Equalization
• We have to search for a transform that converts any random
histogram into flat histogram.
S = T(r)
• We have to find ‘T’ which produces equal values in each gray
levels
• The Transform should satisfy two conditions:
(i) T(r) must be single value & monotonically increasing
in the interval, 0 ≤ r ≤ 1.
(ii) 0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1
0 ≤ S ≤ 1 for 0 ≤ r ≤ 1
Here, range of r is [0, 1] (Normalized range) instead of [0, 255].
17-12-2021 DIP-SOCS-$P$ 24
Histogram Equalization
17-12-2021 DIP-SOCS-$P$ 25
Histogram Equalization
Applied
Histogram
equalisation
17-12-2021 DIP-SOCS-$P$ 26
Histogram Equalization
Applied
Histogram
equalisation
17-12-2021 DIP-SOCS-$P$ 27
HISTOGRAM MODIFICATION
• Stretch • Shrink • Slide
17-12-2021 DIP-SOCS-$P$ 28
Histogram Modification
• The histogram can be modified by a mapping function
which will stretch, shrink or slide the histogram
• This will change the contrast or brightness of the image
17-12-2021 DIP-SOCS-$P$ 29
Histogram Modification
The graphical representation of histogram stretch
17-12-2021 DIP-SOCS-$P$ 30
Histogram Modification
The graphical representation of histogram Shrink
17-12-2021 DIP-SOCS-$P$ 31
Histogram Modification
The graphical representation of histogram Slide
17-12-2021 DIP-SOCS-$P$ 32
Histogram Modification
STRECH
The mapping equation for histogram stretch:
17-12-2021 DIP-SOCS-$P$ 33
Histogram Modification
17-12-2021 DIP-SOCS-$P$ 34
Histogram Modification
17-12-2021 DIP-SOCS-$P$ 35
Histogram Modification
17-12-2021 DIP-SOCS-$P$ 36
Histogram Modification
SHRINK
17-12-2021 DIP-SOCS-$P$ 37
Histogram Modification
17-12-2021 DIP-SOCS-$P$ 38
Histogram Modification
SHRINK
17-12-2021 DIP-SOCS-$P$ 39
Histogram Modification
SHRINK
17-12-2021 DIP-SOCS-$P$ 40
Histogram Modification
SLIDE
17-12-2021 DIP-SOCS-$P$ 41
HISTOGRAM SPECIFICATIONS
• While the goal of histogram equalization is to produce an output
image that has a flattened histogram,
• The goal of histogram Specifications (matching) is to take an input
image and generate an output image that is based upon the shape of a
specific (or reference) histogram
• Histogram Specification is also known as histogram Matching
• Histogram equalization can be considered as a special case of
histogram matching
in which we want to force an image to have a uniform histogram (rather than
just any shape as is the case for histogram matching)
17-12-2021 DIP-SOCS-$P$ 42
HISTOGRAM SPECIFICATIONS
17-12-2021 DIP-SOCS-$P$ 43
HISTOGRAM SPECIFICATIONS
17-12-2021 DIP-SOCS-$P$ 44
HISTOGRAM SPECIFICATIONS
17-12-2021 DIP-SOCS-$P$ 45
Spatial averaging
• Many image enhancement techniques are based on spatial operations
performed on local neighbourhoods of input pixels.
17-12-2021 DIP-SOCS-$P$ 46
Spatial averaging
• Each pixel is replaced by its average with the average of its nearest
four pixels
17-12-2021 DIP-SOCS-$P$ 47
Spatial averaging
Spatial averaging is used for noise smoothing, low-pass filtering, and sub-sampling
of images
◦ Suppose the observed image is given as
y(m,n) = u(m,n) + η(m,n)
◦ where η(m,n) is white noise with zero mean and variance σ2ᶯ
◦ where η¯(m, n) is the spatial average of η(m,n) It is a simple matter to show that
η¯(m, n) has zero mean and variance σ2ᶯ/ Nw
◦ If the noiseless image u(m, n) is constant over the window W, then spatial
averaging results in an improvement in the output signal-to-noise ratio by a factor
of Nw.
17-12-2021 DIP-SOCS-$P$ 48
Spatial averaging
17-12-2021 DIP-SOCS-$P$ 49
Directional Smoothing
In practice the size of window w is limited due to the fact that u(m,n) is not really constant,
so that spatial averaging introduces a distortion in the form of blurring.
17-12-2021 DIP-SOCS-$P$ 50
Directional Smoothing
• Spatial averages v (m, n : θ) are calculated in several directions
17-12-2021 DIP-SOCS-$P$ 51
Directional Smoothing
17-12-2021 DIP-SOCS-$P$ 52
Median Filtering
The input pixel is replaced by the median of the pixels contained in a
window around the pixel
v(m,n)= median{y(m-k,n-1),(k,l)єW}
The algorithm for median filtering requires arranging the pixel values in
the window in increasing or decreasing order and picking the middle
value
Generally the window size is chosen so that Nw is odd.
If Nw is even, then the median is taken as the average of the two values
in the middle.
Typical windows are 3 x 3, 5 x 5, 7 x 7, or the five-point window
considered for spatial averaging
17-12-2021 DIP-SOCS-$P$ 53
Example
◦ Let {y (m)} = {2, 3, 8, 4, 2} and W = [ -1, 0, 1].
◦ The median filter output is given by
◦ v (0) 2 (boundary value)
v (l) = median {2, 3, 8} = 3
v (2) = median {3, 8, 4} = 4
v (3) = median {8, 4, 2} = 4
v (4) = 2 (boundary value)
◦ Hence {v (m)} = {2, 3, 4, 4, 2}.
◦ If W contains an even number of pixels-for example,
W = [-1, 0, 1,2]-then v(0) = 2, v (l) = 3
v (2) = median {2, 3, 8, 4}= (3 + 4)/2 = 3.5, and so on
◦ gives {v (m)} = {2, 3, 3.5, 3.5, 2}.
17-12-2021 DIP-SOCS-$P$ 54
• The median filter has the following properties:
• It is a nonlinear filter. Thus for two sequences x (m) and y (m)
median{x(m) + y (m)} ≠ median{x (m)} + median{y (m)}
17-12-2021 DIP-SOCS-$P$ 57
Frequency Domain Enhancement
• In Frequency domain methods the image is first transferred into
frequency domain
17-12-2021 DIP-SOCS-$P$ 58
Frequency Domain Enhancement
• These enhancement operations are performed in order to modify the
image brightness, contrast or the distribution of the grey levels
17-12-2021 DIP-SOCS-$P$ 59
Frequency Domain Enhancement
• The Image enhancement simply means, transforming an image F into
Image G using T [where T is the transformation function]
17-12-2021 DIP-SOCS-$P$ 60
Frequency Domain Enhancement
17-12-2021 DIP-SOCS-$P$ 61
Frequency Domain Enhancement
We can therefore directly design a transfer function and implement the enhancement
in the frequency domain
17-12-2021 DIP-SOCS-$P$ 62
Filtering
• The concept of filtering is easier to visualize in the frequency domain
• Enhancement of image can be done in the Frequency domain, based on its DFT
17-12-2021 DIP-SOCS-$P$ 63
Filtering
17-12-2021 DIP-SOCS-$P$ 64
Low Pass Filtering
17-12-2021 DIP-SOCS-$P$ 65
Low Pass Filtering
17-12-2021 DIP-SOCS-$P$ 66
Low Pass Filtering
17-12-2021 DIP-SOCS-$P$ 67
Low Pass Filtering
17-12-2021 DIP-SOCS-$P$ 68
Low Pass Filtering
17-12-2021 DIP-SOCS-$P$ 69
Low Pass Filtering
17-12-2021 DIP-SOCS-$P$ 70
Low Pass Filtering
17-12-2021 DIP-SOCS-$P$ 71
Low Pass Filtering
17-12-2021 DIP-SOCS-$P$ 72
Low Pass Filtering
17-12-2021 DIP-SOCS-$P$ 73
Low Pass Filtering :
17-12-2021 DIP-SOCS-$P$ 74
Low Pass Filtering : Butterworth low
pass filter
17-12-2021 DIP-SOCS-$P$ 75
Low Pass Filtering : Butterworth low
pass filter
17-12-2021 DIP-SOCS-$P$ 76
Low Pass Filtering : Butterworth low
pass filter
17-12-2021 DIP-SOCS-$P$ 77
Low Pass Filtering : Butterworth low
pass filter
Ringing is an image artifact that may appear when Doing Deconvolution under certain
conditions. It produces dark and light ripples around bright features of an image
17-12-2021 DIP-SOCS-$P$ 78
Low Pass Filtering : Gaussian low pass
filter
17-12-2021 DIP-SOCS-$P$ 79
Low Pass Filtering : Gaussian low pass
filter
17-12-2021 DIP-SOCS-$P$ 80
Low Pass Filtering : Gaussian low pass
filter
Example
17-12-2021 DIP-SOCS-$P$ 81
High Pass Filtering
17-12-2021 DIP-SOCS-$P$ 82
High Pass Filtering
17-12-2021 DIP-SOCS-$P$ 83
High Pass Filtering
17-12-2021 DIP-SOCS-$P$ 84
High Pass Filtering
17-12-2021 DIP-SOCS-$P$ 85
High Pass Filtering
17-12-2021 DIP-SOCS-$P$ 86
High Pass Filtering
17-12-2021 DIP-SOCS-$P$ 87
High Pass Filtering : example of IHPF
17-12-2021 DIP-SOCS-$P$ 88
High Pass Filtering : example of BHPF &
GHPF
17-12-2021 DIP-SOCS-$P$ 89
Low Pass High Pass
Filtering Filtering
An image can be smoothed in the Frequency An image can be smoothed in the Frequency
domain by reducing the High-frequency domain by reducing the low-frequency
content of its Fourier transform content of its Fourier transform
17-12-2021 DIP-SOCS-$P$ 90
Low Pass High Pass
Filtering Filtering
17-12-2021 DIP-SOCS-$P$ 91