Unit - 4 Image Enhancement (Part A)
Unit - 4 Image Enhancement (Part A)
REFERENCE
[1] R.C Gonzalez and Richard Woods, Digital Image Processing, Pearson
Publication
Image Enhancement
• Process of manipulating image so that it becomes more suitable for a specific operation
• Enhancement techniques are problem oriented
• Method suitable for enhancement of X-ray might not be suitable for satellite images
• Spatial domain:
• Image plane itself
• Image processing methods involve manipulation directly on the pixels in the image
• Frequency/Transform Domain
• Involves transforming the image into transform domain
• Some processing done in transform domain to enhance the image
• Image converted back to spatial domain
• Histogram Processing
IMAGE EHANCEMENT- Spatial Domain
Ami Munshi
Spatial Domain Techniques
• Spatial domain:
• Image plane itself
• Image processing methods involve manipulation directly on the pixels in the
image
(0,0)
y • Neighbour hood is rectangular, centered on (x,y), and
much smaller in size than the original image
x
Intensity or gray level transformation
(0,0)
y • Smallest possible neighbourhood size is 1X1
s= T(r)
x
Image Enhancement
Point Processing Techniques
Intensity or gray level transformation Techniques
or Point Processing Techniques
s= T(r)
• Three basic types of functions used frequently for image enhancement are
• Linear point processing techniques
• Identity transformation
• Digital negative transformation
• Non linear
• Logarithmic transformation (Log and inverse log)
• Power law (Gamma) transformation (nth power and nth root)
Intensity level transformation techniques
• Linear
• Negative/Identity
• Logarithmic
• Log/Inverse log
• Power law
• nth power/nth root
s
Output intensity is equal to input intensity
L-1
s=r
r
0 L-1
Identity Transformation
Linear Point Transformation
-Digital Negative Transformations
s= L-1-r
Solution:
Therefore, n=3 → L= 8
Example: Find negative image for the given image
s= L-1-r
Digital Negative Example
g(x,y)
f(x,y)
Digital Negative Example
Non linear Point Processing technique
• Logarithmic Transformation
• Power Law Transformation
Logarithmic Transformations
• Logarithmic transformation is divided into two types:
• Log transformation
• Inverse log transformation
• The log transformation maps a narrow range of low input values into a wider range of output values
• The inverse log maps a wide range of input values into a narrow range of output values
• The formula for Logarithmic transformation is:
s = c log(r + 1)
• Here, s and r are the pixel values for input and output image. And c is constant.
• In the formula, we can see that 1 is added to each pixel value this is because if pixel intensity is zero
in the image then log(0) is infinity so, to have minimum value one is added.
• When log transformation is done dark pixels are expanded as compared to higher pixel values.
• In log transformation higher pixels are compresses.
Logarithmic Transformations
• The logarithmic operator enhances the low intensity pixel values, while compressing high
intensity values into a relatively small pixel range.
• Hence, if an image contains some important high intensity information, applying the
logarithmic operator might lead to loss of information.
• Thus, a logarithmic transform is appropriate when we want to enhance the low pixel values
at the expense of loss of information in the high pixel values. For example,
Logarithmic Transformations
• On the other hand, applying a logarithmic transform to this image is less appropriate,
because most of its details are contained in the high pixel values.
• Inverse log does opposite function to the log transformations.
• It is used to expand the values of high pixels in an image while compressing the darker-level
values.
Logarithmic Transformations
• Inverse log does opposite function to the log transformations.
• It is used to expand the values of high pixels in an image while compressing the darker-level
Logarithmic Transformations
• Any curve with general shape of log functions will accomplish spreading/compressing of intensity
levels in an image
• Important characteristic of log function is to compress dynamic range of images with large vatiation
in pixel value.
• s = c * log (1+ r)
• For r = 0 , s=0
• For r = 106
• s = log10 (1+ 106) = 6
• Range of 0 to 106 becomes 0 to 6.2 on log scale
Power Law Transformation
L-1 r s
C
0-10 0-15
s2
10-20 15-25
Modified Image
B 20-30 25-30
s1
r
0 r1 r2 L-1
A Original Image
Piecewise linear
-Contrast Stretching
Example: Perform contrast stretching on the following image according to the transfer function shown
Piecewise linear
-Contrast Stretching
Example: Perform contrast stretching on the following image according to the transfer function shown
Example: Perform contrast stretching on the following image according to the transfer function shown
5 3 2 4 0 6
Modified Image
4 2 2 1 0
1 7 6 4 5
1
2 3 0 6 7
r s
For the first segment, m = (1-0)/(3-0)= 0.3
0 3 7 5 2
and s= m*r 0
5 3 2 4 0
For the second m = (6-1)/(5-3)= 2.5 1
4 2 2 1 0
and s= m*(r-r1) + s1
2 1 7 6 4 5
For the third segment, m = (7-6)/(7-5)= 0.5 3
Modified Image
and s= m*(r-r2) + s2
4
5
6
7
Piecewise linear
-Thresholding
Contrast Stretching
s
B s2 = L-1
s1
r
0 r1 r2 L-1
A Original Image
Piecewise linear
-Thresholding
Thresholding
s
• Contrast stretching becomes
L-1 =s2 Thresholding if
r1 = r2
s1 = 0 and
s2 = L-1
Modified Image
For thresholding
s= L-1 for r ≥ r1
s1=0 r s= 0 for r < r1
r1=r2 L-1
Here r1 is the threshold level
Original Image
Example
s
7 • The given transformation is
applied to the image given below.
• What will be the pixel intensity at
(3,4) in the enhanced image?
Modified Image
1 1 1 2 2
3 3 3 4 4
r 4 4 1 1 1
0 3 7 2 2 5 5 2
Original Image
7 7 6 6 6
Piecewise linear
-Thresholding
0 2 3 2 1 0 7 7 7 0
3 0
0 0 0 0 0
4 7
s= L-1 for r ≥ r1
s= 0 for r < r1 5 7
6 7
s= 7 for r ≥ 4
s= 0 for r < 4 7 7
Piecewise linear
-Grey Level Slicing/Intensity Level Slicing
s
L-1
• s = s1 for r < r1
s2 • s = s2 for r1 ≤r ≤ r2
Modified Image
• s = s1 for r > r2
s1
r
s1 r1 r2 L-1
Original Image
Piecewise linear
-Grey Level Slicing/Intensity Level Slicing-with
background
s
L-1 • s = r for r < r1
s2 • s = s2 for r1 ≤r ≤ r2
• s = r for r > r2
Modified Image
s1=0 r
r1 r2 L-1
Original Image
Piecewise linear
-Grey Level Slicing/Intensity Level Slicing-without
background
• Example: Implement grey level slicing with background and without background where r1= 2
and r2= 4
0 2 3 2 1 • s = 7 for r1 ≤r ≤ r2 7 0 0 0 0
0 7 7 7 0
• s = 0 for r > r2
Piecewise linear
-Grey Level Slicing/Intensity Level Slicing-with
background
• Example: Implement grey level slicing with background and without background where r1= 2
and r2= 4
0 1 1 1 1 0 1 1 1 0 0 1
0 0 1 1 1 0 0 0 0 0 0 1
0 0 1 0 0 1 1 1 1 0 0 1
1 1 1 0 1 0 0 1 1 1 0 0
Calculate Root Mean Square Error (RMS) using the following formula
𝑀−1 𝑁−1
1 2
𝑟𝑚𝑠 𝑒𝑟𝑟𝑜𝑟 = 𝑠 𝑖, 𝑗 − 𝑟 𝑖, 𝑗
𝑀𝑁
𝑖=0 𝑗=0
3 4 6 7 2 4 6 6
rms error =
2 0 4 5 2 0 4 4
1 2 6 3 0 2 6 2
7 5 4 2 6 4 4 2
Original Image New image
Thank you