Lec 3 Image Processing
Lec 3 Image Processing
(CSC 352)
2022 – 2023
Lecture-3
Dr: Mary monir saied
Email: [email protected]
Digital Image Fundamentals
Image Enhancement
Fundamental Steps of DIP
3
Agenda
Introduction
Image Enhancement – Point Processing
Simple intensity (gray level) transformations
Basic Intensity Transformation
1. Linear Functions:
2. Logarithmic Functions:
3. Power-Law Functions:
piecewise Linear transformation functions.
1. Contrast stretching
2. Gray-level slicing
3. Bit-plane slicing
Histogram processing
Histogram equalization 4
Arithmetic operations
Introduction
What is Image Enhancement
Images are obtained from various sensor outputs.
6
What is Image Enhancement
The principal objective of enhancement
Process an image so that the result is more
suitable than the original image for a specific
application.
The suitability depends on each specific application
A method useful for enhancing a certain image
may not necessarily be the best approach for
enhancing other types of images.
Regardless of the method used, however, image
enhancement is one of the most interesting and
visually appealing areas of image processing. 7
What is Image Enhancement
9
What is Image Enhancement
10
Domains of Image Enhancement
It is a mathematical procedure
done in data (digital images)
that converts it from one
domain to another, usually
doing Fourier's.
11
Domains of Image Enhancement– (cont.)
12
Domains of Image Enhancement
13
Image Enhancement Methods
Spatial Domain Methods (Image Plane)
Techniques are based on direct manipulation of pixels in an
image
Combination Methods
There are some enhancement techniques based on various
combinations of methods from the first two categories
14
In this chapter, we are going to discuss spatial domain
techniques
Spatial domain
15
Spatial domain
Spatial domain processes:
17
Point Processing
Point
processing
Gray- Bit-
Linear Logarithmic Power-Law Contrast
level plane
Functions Functions Functions stretching
slicing slicing
Inverse-
Log
log
18
Point Processing
Gray-level (Intensity) Transformation Functions
Here, T is called intensity transformation function or ( gray
level function)
19
Point Processing
Point
processing
Gray- Bit-
Linear Logarithmic Power-Law Contrast
level plane
Functions Functions Functions stretching
slicing slicing
Inverse-
Log
log
20
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Three basic types of functions used frequently for image
enhancement:
21
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Linear Functions:
1- Image Negatives
• The negative of an image with gray level in the range [0, L-1],
where L = Largest value in an image, is obtained by using the
negative transformation’s expression:
s = L-1- r
• Which reverses the intensity levels of an input image , in this
manner produces the equivalent of a photographic negative.
• The negative transformation is suitable for enhancing white or 22
gray detail embedded in dark regions of an image, especially
when the black area are dominant in size.
Intensity Transformation Functions
Linear Functions:
1- Image Negatives
s
L-1
23
L-1
r
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Linear Functions:
1- Image Negatives s = L-1- r
24
Intensity Transformation Functions
Linear Functions:
1- Image Negatives
Advantages of negative : 25
Produces an equivalent of a photographic negative.
Enhances white or gray detail embedded in dark regions.
Intensity Transformation Functions
Linear Functions:
1- Image Negatives
Example:
Compute the negative of the following 4-bit/pixel image
2 10 4 13 5 11
15 14 13 0 1 2
7 3 6 8 12 9
Original image Output image
Solution: 26
S=L – 1 – r
L= 16
S= 15 - r
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Linear Functions:
2- Image Identity
s=r
Output intensities
are identical to
input intensities.
27
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Linear Functions:
2- Image Identity
Identity transition is shown by a straight line. In this transition, each
value of the input image is directly mapped to each other value of output
image. That results in the same input image and output image. And
hence is called identity transformation. It has been shown below:
s s=r
L-1
This function doesn’t have an
effect on an image, it was
included in the graph only for
completeness.
28
0 L-1
r
Point Processing
Point
processing
Gray- Bit-
Linear Logarithmic Power-Law Contrast
level plane
Functions Functions Functions stretching
slicing slicing
Inverse-
Log
log
29
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Logarithmic Functions:
1- Log Transform
• The general form of the
log transformation:
s = c log (1+r)
Where c is a constant, and r ≥ 0
• Log curve maps a narrow
range of low gray-level
values in the input image
into a wider range of the
output levels. 30
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Logarithmic Functions:
1- Log Transform L-1
31
s = c log(1+ r)
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Logarithmic Functions:
1- Log Transform
32
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Logarithmic Functions:
2- Inverse Log Transform
Do opposite to the log
transformations
Used to expand the values of
high pixels in an image while
compressing the darker-level
values
33
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Logarithmic Functions:
2- Inverse Log Transform
L-1
Output intensity level, s
0 34
0 L-1
Input intensity level, r
Intensity Transformation Functions
InvLog Log
35
Point Processing
Point
processing
Gray- Bit-
Linear Logarithmic Power-Law Contrast
level plane
Functions Functions Functions stretching
slicing slicing
Inverse-
Log
log
36
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Power-law Functions:
s = c. 𝒓𝜸
Where c and 𝜸 are
positive constants.
Power-law curves with fractional values of 𝜸 map a values into a wider range
37
of outputs, with the opposite being true for higher values of input levels.
C= 𝜸=1 identity function
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Power-law Functions:
38
Gamma < 1
Different power
values highlight
different details.
40
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Power-law Functions:
41
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Power-law Functions:
γ = 5.0
42
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Power-law Functions:
43
Intensity Transformation Functions
1-Basic Intensity Transformation Functions
Power-law Functions:
Normal
• power-law Gamma < 1
transformations New Range
are useful for
general-purpose
contrast
manipulation Gamma > 1
Old Range
Intensity Transformation Graph
If 𝜸< 1: the mapping is weighted toward brighter output values. 44
If 𝜸= 1: the mapping is linear.
If 𝜸 > 1: the mapping is weighted toward dark output values.
Point Processing
Point
processing
Gray- Bit-
Linear Logarithmic Power-Law Contrast
level plane
Functions Functions Functions stretching
slicing slicing
Inverse-
Log
log
45
Intensity Transformation Functions
2-piecewise Linear transformation functions.
Principle Advantage:
Some important transformations can be formulated only as a
piecewise function.
Principle Disadvantage:
Their specification requires more user input that previous
transformations.
Gray- Bit-
Linear Logarithmic Power-Law Contrast
level plane
Functions Functions Functions stretching
slicing slicing
Inverse-
Log
log
47
Intensity Transformation Functions
2-piecewise Linear transformation functions.
• Contrast Stretching
• One of the simplest piecewise linear functions is a contrast-
stretching transformation, which is used to enhance the low
contrast images.
48
Intensity Transformation Functions
2-piecewise Linear transformation functions.
• Contrast Stretching
Contrast can be simply explained as the difference between
maximum and minimum pixel intensity in an image.
The following example shows three 8-bit images with different
contrast level
100 100 100 100 0 5 7 9 100 106 109 100
100 100 100 100 20 10 30 60 120 122 135 140
100 100 100 100 100 130 180 190 110 115 117 120
100 100 100 100 200 221 230 255 130 136 145 150
50
The idea behind contrast stretching is to increase the dynamic
range of the gray levels in the image being processed.
Intensity Transformation Functions
2-piecewise Linear transformation functions.
• Contrast Stretching
Improves the contrast in an
image by stretching the
range of intensity values to
span a desired range of
values.
52
𝑠𝑚𝑎𝑥 − 𝑠𝑚𝑖𝑛 54
𝑠= × (𝑟 − 𝑟𝑚𝑖𝑛 ) + 𝑠𝑚𝑖𝑛
𝑟𝑚𝑎𝑥 − 𝑟𝑚𝑖𝑛
Intensity Transformation Functions
2-piecewise Linear transformation functions.
• Contrast Stretching: example
Input image: 8-bit image have range [100-151]
After contrast stretching: the new range become [0 -255]
Using the following equation:
𝑠𝑚𝑎𝑥 − 𝑠𝑚𝑖𝑛
𝑠= × (𝑟 − 𝑟𝑚𝑖𝑛 ) + 𝑠𝑚𝑖𝑛
𝑟𝑚𝑎𝑥 − 𝑟𝑚𝑖𝑛
𝑠𝑚𝑎𝑥 − 𝑠𝑚𝑖𝑛
𝑠= × (𝑟 − 𝑟𝑚𝑖𝑛 ) + 𝑠𝑚𝑖𝑛
𝑟𝑚𝑎𝑥 − 𝑟𝑚𝑖𝑛
𝟐𝟓𝟓 − 𝟎
𝒔= × 𝒓 − 𝟏𝟎𝟎 + 𝟎 = 𝟓 × 𝒓 − 𝟏𝟎𝟎
𝟏𝟓𝟏 − 𝟏𝟎𝟎 57
Intensity Transformation Functions
2-piecewise Linear transformation functions.
• Contrast Stretching
Ans.:
𝟐𝟓𝟓 − 𝟎
𝒔= × 𝒓 − 𝟏𝟎𝟎 + 𝟎 = 𝟓 × 𝒓 − 𝟏𝟎𝟎
𝟏𝟓𝟏 − 𝟏𝟎𝟎
If r=100 s=0
If r=105 s=25 100 105 107 100
If r=107 s=35 120 125 120 130
If r=112 s=60 115 117 112 118
If r=115 s=75
If r=117 s=85 130 140 145 151
If r=118 s=90
If r=120 s=100 Input image
If r=125 s= 125
If r= 130 s= 150
If r=140 s=200 58
If r=145 s=225
If r=151 s=255
Intensity Transformation Functions
2-piecewise Linear transformation functions.
• Contrast Stretching
Ans.: