You are on page 1of 210

Digital Image

Processing

Lecture
Dr. Rajib Kumar Jha
Associate Professor
Notes-2019 Depart of Electrical Engineering
Indian Institute of Technology Patna
jharajib@iitp.ac.in
1
Lecture-11-12-13-14
Image Enhancement

2
Contents
• Image Enhancement
• Point Processing
• Mask Processing
• Gray level Slicing
• Dynamic Range Compression
• What is histogram?
• Histogram Equalization
• Image Subtraction
• Image Averaging
Image Enhancement
• Processing an image to enhance certain
features of the image
• The result is more suitable than the original
image for certain specific applications
– Processing techniques are very much problem
oriented
– Best technique for enhancement of HDR-image
may not be the best for enhancement of dark
image or low contrast image.
– So, it is application dependent.
4
Different Enhancement Techniques
Enhancement techniques fall under two broad
categories
• Spatial Domain Technique
– Work on image plane itself
– Direct manipulation of pixels in an image
• Frequency Domain Technique
– Modify Fourier Transform coefficient of an image
– Take inverse Fourier Transform of the modified
coefficients to obtain the enhanced image,
8
DCT-based Enhanced image
Effect on Wavelet Transform Coefficients

Dark Input Image

10
Effect of DWT Coefficients
Approximation, n=5

Horizontal, n=5

Vertical, n=5

Diagonal, n=5

50-Iterations

11
Effect on DWT Coefficients
Approximation, n=10

Horizontal, n=10

Vertical, n=10

Diagonal, n=10

100-Iterations

12
Effect on DWT Coefficients
Approximation, n=15

Horizontal, n=15

Vertical, n=15

Diagonal, n=15

150-Iterations

13
Variation of mean and variance of LL (approximation) subband coefficients
with iterations

14
Spatial Domain Technique-Neighbourhood

g(x)=T[f(x)]
g(x,y)=T[f(x,y)

1. For 2-dimensional images g (x, y) is equal to some


transformation T of the image f (x, y).
2. f (x, y) is the original image, T is transformation which is applied
on this original image to give the processed image g (x, y).
Point Processing: Neighbourhood size is 1x1

• r= intensity value of original image; S=Processed image;


Transformation T is working directly on f (x, y) that is, in the spatial
domain will give the processed image g (x, y).
• Second fig., it actually generates a binary image consisting of only the
low values and high values, This operation is know as thresholding.
Mask Processing

If neighborhood size is more than 1x1, i.e., of 3x3 or


5x5 and 7x7 so on
Median filtered image_3x3 & 5x5 mask
Median filtered image_3x3 & 5x5 mask

19
Point Processing-Image Negative

Gray level information is embedded in very-very dark pixels and


the nature of the information is such that we have very few gray
level information present in a white background.
Image Negative
Negative of an Image
Image Negative

26
Why Contrast stretching Enhancement?
• When less intensity light falls on image scene.
• Next question ? Why an image is dark?
• It is due to the dynamic range of the sensor.
• Dynamic range is the capacity of the sensor to
record minimum intensity value and maximum
intensity value.
• So, difference between the minimum and the
maximum intensity value is the dynamic range of
the sensor.
• If scene is properly illuminated but sensor is not
capable of recording all those variations in the
scene intensity, that leads to very a dark image. 27
Contrast stretching Enhancement
Contrast Stretching
Contrast Stretching Result
Contrast Stretching Result

34
35
Dynamic Range Compression

• The applications where we need to reduce the dynamic range is, I have an original
image whose dynamic range is so high (0 to thousand) that it cannot be properly
reproduced by our display device (0 to 255).
• So the display device will mostly display the highest intensity values and the lower
intensity values will be in most of the cases suppressed by that.
Log Transformation
Dynamic Range Compression
Power Law Transformation: Gamma Correction
• When value of gamma is less than 1. The response of transformation
function is more towards the larger range of lower intensity input image
• for a higher intensity side, a higher range of input intensity is mapped to
a lower range of intensity values in processed image
• The reverse is true for values of gamma greater than 1.
Gray Level Slicing
Gray Level Slicing
Gray Level Slicing
48
Bit Plane Slicing
Bit Plane Slicing
Bit Plane Slicing
52
53
Image Subtraction & Change Detection
Lena, watermarked lena (WML) &
difference between lena and WML

55
Lena, watermarked lena (WML) & difference between lena and WML

56
Difference of Two Images
g(x,y) =f(x,y)-h(x,y)
Result: Histogram Equalization
Result: Histogram Equalization
Result: Histogram Equalization

67
Result: Histogram Equalization

68
Histogram Equalized Image
71
72
Smoothing Spatial filter
76
77
Result of Averaged Image

• Sharp edges becomes blur in this process.


• So weighted average filter is defined.
80
Results of Spatial Low-pass Filter
3x3, 5x5, 7x7 masks
Low pass filtered image
Low pass filtered image
84
86
87
90
91
92
93
Results of Median Filter
Box Filter and Median Filter
Box filter

Median filter operation maintains the sharpness and contrast of


the image as compared to Box Filter.
5x5 Box and Median filtered image
Min, Max & Median filtered image

98
Sharpening Spatial Filter
• Averaging over an image creates blurring in the image or
the details in the image are removed.
• Averaging operation is equivalent to integration
operation.

• If integration gives a smoothing effect, it is quite logical to


think that if I do the opposite operation that is instead of
integration,

• if I do differentiation operation, then the sharpness of


the image is likely to be increased.
• So, it is the derivative operations or the differentiation
which are used to increase the sharpness of an image.
First order and Second order derivative response

Isolated point

ramp Thin lines step

Flat
First order and Second order derivative response

Isolated point

ramp Thin lines step

Flat
Laplacian Edge detection
Composite Laplacian Mask
123
Laplacian operator can detect changes
in all directions

124
125
126
127
128
Results

129
130
131
137
Comparative Results
Results of Sobel Operator

• It highlights the edge region and discontinuity region of an image


Sobel Operator
Unsharp masking

High boost filtering. Choosing K<1 reducing the contribution of the


unsharp mask.
149
150
151
High-boost filtering result
1-D Gaussian function
• In Frequency domain take FT of f(x,y) and FT of mask and
take the product;

• Now Analyse it using Gaussian function because shape of


Gaussian can be easily analysed and FT of Gaussian is
Gaussian only
161
Analysis of Gaussian Profile
• H (u) in the frequency domain and h (x) in the spatial
domain, both are Gaussian & real functions.
• They behave reciprocally with each other.
• When H(u) in the frequency domain has a broad profile
i.e, it has a large value of sigma. The corresponding h(x)
in the spatial domain will have a narrow profile.
• Similarly, if H (u) has narrow profile, h (x) will have a
broad profile.
• When this sigma tends to infinity, function H (u) tends
to be a flat function.
• In such case, the corresponding spatial domain filter h (x)
tends to be an impulse function. So, this shows that both
H (u) and h (x), are reciprocal to each other.
Low Pass Filter

1. The narrower the frequency domain filter, more it will attenuate


the low pass frequency components resulting in more blurring
effect.
2. Making the frequency domain filter narrower, means
corresponding spatial domain filter or spatial domain mask will be
flatter. That means mask size in the spatial domain will be larger.
164
165
Low Pass filter in frequency Domain
• Edges as well as sharp transitions like noises, they
lead to high frequency components in the image
• if we want to reduce these high frequency
components, then the kind of filter that we have to
use is a low pass filter.
• low pass filter allows the low frequency
components of the input image to be passed to the
output and
• It will cut off the high frequency components of the
input image which will not be passed to the output.
Low Pass Filter Mask

In the spatial domain, the mask size will be larger and


if I use a larger mask size for smoothing operation,
then the image gets more and more blurred.
High Pass Filter
−𝑢2
• 𝐻 𝑢 = 𝐴[1 − 𝑒 2𝜎2 ]

−2𝜋2 𝜎 2 𝑥 2
• h(x)=A[𝛿 𝑥 − 2𝜋𝐴𝑒 ]

168
High-pass Filter

1. it will attenuate the low frequency components


whereas it will pass the high frequency components
2. The corresponding filter in the spatial domain is having
this form which is given by h (x) as the function of x.
Laplacian Mask
Laplacian operator has similar nature to the HPF in
spatial domain discussed in previous slide

This masks are Laplacian masks in the spatial domain, the kind of
operation that is done is basically a high pass filtering operation.
Basic Model of Low Pass filter in
frequency Domain
𝐺 𝑢, 𝑣 = 𝐻 𝑢, 𝑣 . 𝐹(𝑢, 𝑣)

r0 is the distance of the point (u, v) in the frequency


domain from the origin of the frequency rectangle.
Ideal Low Pass Filter
178
179
180
Low Pass Filter Result

Input noiseless image and Noisy Image


Ideal and Butterworth Low pass Filter

Cut-off
frequency
Ringing effect
Disadvantage
• At same cut-off frequency 10, blurring of low pass
filtered image is large compared to the blurring
introduced by the butter-worth low pass filter.
• If increase the cut off frequency to 20; in the ideal
low pass filtered image the image is very sharp but
the disadvantage is the ringing effect present.
• That means there are a number of undesired lines
which are not present in the original image, that
are present.
• Spread of this main component is inversely proportional
to D0 which is cut off frequency of the ideal low pass filter.
• All the secondary components over an unit length is again
inversely proportional to this cut off frequency D0 and
these are the one responsible for ringing effect.
Butterworth Filter
• So, butter worth filter of order 1 does not
leads to any kind of ringing effect.
Whereas, if we go for butter worth filter
of higher order that may lead to the
ringing effect.
• if I use a Gaussian low pass filter for
filtering operation we will never have any
ringing effect in the processed image.
Ideal High Pass
Butterworth High Pass Filter
Ideal & Butterworth high pass Filter
Ideal & Butterworth high pass filter

you can find there are ringing effects around this boundaries in
ideal filter whereas no ringing effect in butter worth filter.
• Taking the Fourier transform directly on this
product is not possible.
• Define a function g(x,y,z) which is ln[f(x,y,z)]
and is nothing but ln[i(x,y,z) + ln[r(x,y,z)]
Homomorphic Filter
Homomorphic Filter
• The first term is the illumination component and
second term is the reflectance component.
• Illumination component leads to low frequency
components because illumination is slowly
varying
• The reflectance component leads to high
frequency components, particularly at the
boundaries of 2 reflecting objects.
• We try to design a filter which can enhance the
high frequency components and attenuate the
low frequency components.
205
Homomorphic Filter
Homomorphic Filter
Thanks

210

You might also like