PDF-FSK IVP Ch6 Image Enhancement 2023
PDF-FSK IVP Ch6 Image Enhancement 2023
Dr Faruk Kazi
VJTI Mumbai
Module VI-
Image Enhancement
Image Enhancement-
Spatial Domain Methods
• Spatial Domain- (Space coordinates)
• Transformed Domain- (DFT, DCT, DWT, Hadamard Transform)
Image Enhancement-
Spatial Domain Methods
• Spatial Domain- (Space coordinates)
• Transformed Domain- (DFT, DCT, DWT, Hadamard Transform)
Image Enhancement-
Spatial Domain Methods
Image Enhancement-
Spatial Domain Methods
Point Operations Neighbourhood Operations
(Zero memory operations)
Image Enhancement-
Spatial Domain Methods
Point Operations • Identity Transform
(Zero memory operations) • Image Negative
• Contrast Stretching
• Thresholding
• Intensity-Level Slicing
• Bit-Plane Slicing
• Log Transform
• Power-Law (Gamma) Transform
Spatial Domain Methods-
Point Operations
1. Identity Transform 2. Image Negative 3. Contrast Stretching
Spatial Domain Methods-
Point Operations
3. Contrast Stretching
Spatial Domain Methods-
Point Operations
3. Contrast Stretching
Spatial Domain Methods-
Point Operations
3. Contrast Stretching
Spatial Domain Methods-
Point Operations
3. Contrast Stretching 4. Thresholding
1 6 7
2 6 7
Spatial Domain Methods-
Point Operations
6. Bit-plane Slicing (LSB/MSB)
0 6 7 000 110 111
0 1 1 0 1 1 0 0 1
0 1 1 0 0 0 1 0 1
0 1 0 1 1 1 0 0 1
Spatial Domain Methods-
Point Operations
6. Bit-plane Slicing (LSB/MSB)
0 6 7 000 110 111
0 1 1 0 1 1 0 0 1
0 1 1 0 0 0 1 0 1
0 1 0 1 1 1 0 0 1
LSB Slicing
Spatial Domain Methods-
Point Operations
6. Bit-plane Slicing (LSB/MSB)
0 6 7 000 110 111 000 110 110 0 6 6
0 1 1 0 1 1 0 0 1
0 1 1 0 0 0 1 0 1
0 1 0 1 1 1 0 0 1
LSB Slicing
Spatial Domain Methods-
Point Operations Application-
Image
6. Bit-plane Slicing (LSB/MSB)
Compression
0 6 7 000 110 111 000 110 110 0 6 6
0 1 1 0 1 1 0 0 1
0 1 1 0 0 0 1 0 1
0 1 0 1 1 1 0 0 1
LSB Slicing
Spatial Domain Methods-
Point Operations Application-
Steganography
6. Bit-plane Slicing (LSB/MSB)
0 6 7 000 110 111 001 110 110 1 6 6
1 0 0
1 1 1
0 1 0
0 1 1 0 1 1 0 0 1
0 1 1 0 0 0 1 0 1
0 1 0 1 1 1 0 0 1
LSB Slicing
Spatial Domain Methods-
Point Operations
7. Log Transform
• It is a nonlinear transform
• It maps a narrow range of low
intensity values in the inputs
into a wider range of output
levels
• Conversely, higher values of
input levels are mapped to a
narrower range in the output
Spatial Domain Methods-
Point Operations
7. Log Transform
• It is a nonlinear transform
• It maps a narrow range of low
intensity values in the inputs
into a wider range of output
levels
• Conversely, higher values of
input levels are mapped to a
narrower range in the output
Spatial Domain Methods-
Point Operations
7. Log Transform
• It is a nonlinear transform
• It maps a narrow range of low
intensity values in the inputs
into a wider range of output
levels
• Conversely, higher values of
input levels are mapped to a
narrower range in the output
• Inverse Log (exponential)
transformation gives the
opposite effect
Spatial Domain Methods-
Point Operations
7. Log Transform
• It does spreading/compressing
of intensity levels in an image
• The log function has the
important characteristics that
it compresses the dynamic
range of pixel values
Spatial Domain Methods-
Point Operations
8. Power-Law (Gamma) Transform
• The response of many devices
used for image capture,
printing and display obey a
power law
• CRT have an intensity-to-
voltage response expressed as
a power function (Gamma= 1.8
to 2.5)
• Such display systems tend to
produce images darker than
intended
Spatial Domain Methods-
Point Operations
8. Power-Law (Gamma) Transform
• Gamma correction- Say, CRT
has gamma of 2.5
• Use transformation s=r1/2.5=r0.4
• Gamma-corrected image
produces an output that is
close in appearance to the
original image
Spatial Domain Methods-
Point Operations
8. Power-Law (Gamma) Transform
Spatial Domain Methods-
Point Operations
8. Power-Law (Gamma) Transform
Original Gamma=
MRI Image 0.6
Gamma= Gamma=
0.4 0.3
Image Enhancement-
Spatial Domain Methods
Summary- Point Operations • Identity Transform
(Zero memory operations) • Image Negative
• Contrast Stretching
• Thresholding
• Intensity-Level Slicing
• Bit-Plane Slicing
• Log Transform
• Power-Law (Gamma) Transform
Example
Exercise- Point Operations
1. Obtain digital negative of the following 8-bit image
2. High-pass filter
Spatial Domain Methods-
Neighborhood Operations
Spatial Filtering
1. Low-pass filter- Averaging filter
Spatial Domain Methods-
Neighborhood Operations
Neighbourhood
121 105 117 156 151Operation
Neighbourhood
121 105 117 156 151Operation
Neighbourhood
121 105 117 156 151Operation
1 1 1
1
Averaging Filter 9
1 1 1
1 1 1
Neighborhood Operations
1 2 3 0
2 4 6 7
5 2 4 3
3 2 6 1
1 1 1
1
9
1 1 1 1
(1+2+3+2+4+6+5+2+4) = 3.22 ≈ 3
1 1 1 9
Neighborhood Operations
1 2 3 0
2 4 6 7
5 2 4 3
3 2 6 1
1 1 1
1
9
1 1 1 1
(1+2+3+2+4+6+5+2+4) = 3.22 ≈ 3
1 1 1 9
1 1 1
1
9
1 1 1
1 1 1
Linear Spatial Filtering
1 1 1
1
9
1 1 1
1 1 1
Linear Spatial Filtering
• A linear spatial filter performs a sum-of-product operation between
an image f and a filter kernel w
• The kernel is an array whose size defines the neighbourhood of
operation, and whose coefficients determine the nature of the filter
• Kernel- mask, template, window
• Kernel is usually of odd size in both coordinate direction (3x3, 5x5
etc), in general mxn, where m=2a+1 and n=2b+1
Linear Spatial Filtering
• Convolution-
y(n)={6, 3, 14, 11, 15, 10, 7, 6}
• Correlation-
rxy(n)={4, 4, 9, 14, 11, 15, 6, 9}
ryx(n)={9, 6, 15, 11, 14, 9, 4, 4}
2D Correlation & Convolution
2D Correlation & Convolution
2D Correlation & Convolution
Correlation & Convolution
Kernels
• Lets understand kernels better-
Averaging Gaussian
Filter/Box Kernel Filter/Kernel
Separable Filter Kernels
• A 2D function G(x,y) is said to be separable if it can be written as
the product of two 1D functions G1 (x) and G2(x); that is,
G(x,y)= G1(x)G2(x)
Outer product
Separable Filter Kernels
• A separable kernel is a matrix that can be expressed as the outer
product of two vectors
• Consider following 2x3 kernel-
Important Property-
Rank of matrix =1
Outer product
Spatial Filtering
• Low Pass Filtering (Smoothing)
• Averaging/Box Filtering
• Gaussian Filter
• High Pass Filtering (Sharpening)
• Order-Statistic (Nonlinear) Filtering
• Median
• Min-Max
Spatial Filtering
• Low Pass Filtering (Smoothing)
• Averaging/Box Filtering
• Gaussian Filter
• High Pass Filtering (Sharpening)
• Order-Statistic (Nonlinear) Filtering
• Median
• Min-Max
High Pass Filtering (Sharpening)
• Based on first & second order derivatives
• For digital/discrete functions- Differences
• Second-order derivative-
Derivative of 2D Function
• First-order derivative-
• Second-order derivative- Laplacian
Derivative of 2D Function
Sharpening Procedure-
Newton
The Gradient-
First order derivatives
The Gradient-
First order derivatives
• Min-max
1 2 3 0
2 3 6 7
5 2 3 3
3 2 6 1
Histogram
Histogram
Histogram- Simple Application
• Deciding threshold from simple bimodal histogram
1 2 3 0
2 3 6 7
5 2 3 3
3 2 6 1
Histogram Processing
• Histogram Stretching
• Histogram Equalization- Histogram Matching
Histogram Processing
• Histogram Stretching
• Histogram Equalization- Histogram Matching
Histogram Processing
• Histogram Stretching
Histogram Processing
Example 1- Histogram Stretching
• Perform histogram stretching for the given image of [0-3] to [0-7]
Grey Levels 0 1 2 3
Number of Pixels 70 20 7 3
Histogram Processing
Example 1- Histogram Stretching
• Perform histogram stretching for the given image of [0-3] to [0-7]
Grey Levels 0 1 2 3
Number of Pixels 70 20 7 3
Grey Levels 0 1 2 3 4 5 6 7
Number of Pixels
Histogram Processing
• Histogram Stretching
• Histogram Equalization/ Histogram Matching
Histogram Processing
Histogram Equalization Histogram Matching
• In this method shape of the histogram is altered
Histogram Processing
Example 1- Histogram Equalization
• Perform histogram equalization for the given image
Grey Levels 0 1 2 3
Number of Pixels 70 20 7 3
-Probability- PDF/CDF
Functions
Additional Reference-
https://ocw.mit.edu/resources/res-18-006-calculus-revisited-single-variable-calculus-fall-2010/part-i-sets-functions-and-limits/lecture-2-functions/
Mathematical Preliminaries-
Histogram Equalization
Functions
Additional Reference-
https://ocw.mit.edu/resources/res-18-006-calculus-revisited-single-variable-calculus-fall-2010/part-i-sets-functions-and-limits/lecture-2-functions/
Mathematical Preliminaries-
Histogram Equalization
Consider intensity
transformation functions
of the following form
Mathematical Preliminaries-
Histogram Equalization
What will happen if it is not monotonic? Otherwise also, we said histogram operations are not invertible !
Artefacts in the image
Consider intensity
transformation functions
of the following form
If Pr(r) and T(r) are known, and T(r) is continuous and differentiable over
the range of values of interest then the PDF of the transformed (mapped)
variable s=T(r) can be obtained as-
Here it goes!
We differentiate s=T(r) by r
We differentiate s=T(r) by r
We differentiate s=T(r) by r
What it means?
Desired Equalized
(z) Histogram (s)
Can we match histogram of our desire
?
Original (r)
Desired Equalized
(z) Histogram (s)
Example- Histogram
Matching/Specification
Original (r)
Equalized
Desired (z)
Histogram (s)
Strictly
monotonic?
Example- Histogram
Matching/Specification
Original
Desired Actual
Equalized
Histogram
Strictly
monotonic?
Example- Histogram
Matching/Specification
Grey Levels (r) 0-1.33 1-3.08 2-4.55 3-5.67 4-6.23 5-6.65 6-6.86 7-7
Number of Pixels 790 1023 850 656 329 245 122 81
Probability 0.19 0.25 0.21 0.16 0.08 0.06 0.03 0.02
Desired/Specified
Grey Levels (z) 0-0 1-0 2-0 3-1.05 4-2.45 5-4.55 6-5.95 7-7
Specified 0 0 0 0.15 0.20 0.30 0.20 0.15
Probability
Example- Histogram
Matching/Specification
r s z
0 0 0
1 1 1
2 2 2 “work-around”
procedure-
3 3 3
We find the smallest
4 4 4 value of zq so that the
value G(zq) is the
5 5 5 closest to sk
6 6 6
7 7 7
Example- Histogram
Matching/Specification
r s z
0 0 0
1 1 1
2 2 2 “work-around”
procedure-
3 3 3
We find the smallest
4 4 4 value of zq so that the
value G(zq) is the
5 5 5 closest to sk
Basically, the strategy
6 6 6 should ensure the
minimum amount of
deformation in the
7 7 7 image.
Example- Histogram
Matching/Specification
r s z
790 0 0 0
1023 1 1 1
850 2 2 2
656 3 3 3
329 4 4 4
245 5 5 5
122 6 6 6
81 7 7 7
Example- Histogram
Matching/Specification
r s z
790 0 0 0
1023 1 1 1
850 2 2 2
656 3 3 3
329 4 4 4
245 5 5 5
122 6 6 6
81 7 7 7
Example- Histogram
Matching/Specification
r s z
790 0 0 0
1023 1 1 1
850 2 2 2
656 3 3 3 790 790/4096=0.19
329 4 4 4
245 5 5 5
122 6 6 6
81 7 7 7
Example- Histogram
Matching/Specification
r s z
790 0 0 0
1023 1 1 1
850 2 2 2
656 3 3 3 790 790/4096=0.19
81 7 7 7 245+122+81 448/4096=0.11
Example- Histogram
Matching/Specification