Lectures 1-4 (Intensity Transformations)
Lectures 1-4 (Intensity Transformations)
SPATIAL FILTERING
SESSIONAL I (Lectures 1 – 4)
Text Books
• R.C.Gonzalez and R.E.Woods, "Digital Image Processing", Addison-
Wesley Longman, Inc, 1999 . (Third Edition preferably)
• A.K.Jain, "Digital Image Processing", PHL
• M.Sonka, V.Hlavac, and R.Boyle – Image processing, Analysis and
Machine vision, Thomson Asia pvt. Ltd, 1999
Chapters of Textbook
1. Introduction
2. Digital Image Fundamentals
3. Intensity Transformations & Spatial Filtering
4. Filtering in the Frequency Domain
5. Image Restoration & Reconstruction
6. Image Compression (Chapter 8)
7. Morphological Image Processing (Chapter 9)
8. Image Segmentation (Chapter 10)
Chapters of Textbook
What is DIP ?
What is DIP ?
• Digital image processing deals with the manipulation of digital images through a
digital computer.
• Scope :
• Process of acquiring an image
• Preprocessing that image
• Extracting (segmenting) the individual characters
• Describing the characters in a form suitable for computer
processing
• Recognizing those characters.
Example of scope of DIP
• Example: Automated analysis of Text
• Scope :
• Process of acquiring an image
• Preprocessing that image
• Extracting (segmenting) the individual characters
• Describing the characters in a form suitable for computer
processing
• Recognizing those characters.
Example of scope of DIP
• Example: Automated analysis of Text
• Scope :
• Process of acquiring an image
• Preprocessing that image
• Extracting (segmenting) the individual characters
• Describing the characters in a form suitable for computer
processing
• Recognizing those characters.
Some important Terms
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
The smallest unit of a digital image or graphic that can be displayed
• Pixel and represented on a digital display device.
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity It is the power per unit area. The value of pixel at a specific location.
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
It is a relative term. Overall lightness or darkness (Average or
• Brightness
mean value of intensity of an image)
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
The difference in brightness between light and dark areas of an
• Contrast image. (Actual indication: Standard Deviation)
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast Indicates brightness of a pixel in a Gray scale image. For a gray scale
• Gray levels image of 8 bit
Min Gray Level = 0 (Black)
Max Gray Level = 255 (White)
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some important Terms
• Pixel
• Intensity
• Brightness
• Contrast
• Gray levels
• Resolution
Some Notations
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Some Notations
• ‘r’ is Input image.
• ‘s’ is Output image.
• 𝑠 𝑥, 𝑦 and r 𝑥, 𝑦 represents arbitrary pixel value of position 𝑥, 𝑦
in output and input image respectively.
• Number of intensity levels in an image is 0 to L – 1. Here, 𝐿 = 2𝑘 . k is
the number of bits used to store a pixel.
• 𝑠 𝑥, 𝑦 = 𝑇[𝑟 𝑥, 𝑦 ] where T is intensity transformation function.
• This can be represented as 𝑠 = 𝑇(𝑟).
Spatial Filtering
Spatial Filtering
Spatial Filtering
Spatial Filtering
Spatial Filtering
Spatial Filtering
Spatial Filtering
Spatial Filtering
Spatial Filtering
Piecewise Linear Transformation
• Contrast Stretching
• Intensity Level Slicing
• Bit Plane Slicing
Contrast Stretching
Contrast Stretching
Contrast Stretching
4 2 6 1
2 7 4 7
1 1 7 6
7 7 4 1
Piecewise Linear Transformation or CS
(Numerical)
4 3 5 2 Original Image
Perform piecewise Contrast stretching according to graph given
3 6 4 6
2 2 6 5
7 6 4 1
4 2 6 1
2 7 4 7
1 1 7 6
7 7 4 1
Intensity Level Slicing
Bit – Plane Slicing
• 256 intensity levels 8 bits to represent a pixel.
• It highlights the contribution made to the total image appearance by
specific
Bit Plane Slicing
Bit Planes 8 & 7
Original Image
Original Image
Original Image
Original Image
• Conditions:
• Conditions:
• Conditions:
• Conditions:
• Conditions:
• Conditions:
• Conditions:
• Conditions:
No
Histogram Matching
Histogram Matching
• Histogram Equalization yields an image whose pixels are (in theory)
uniformly distributed among all gray levels.
• It is useful sometimes to be able to specify the shape of the histogram
that we wish the processed image to have. The method used to
generate a processed image that has a specified histogram is called
histogram matching or histogram specification.
Histogram Matching
• Histogram Equalization yields an image whose pixels are (in theory)
uniformly distributed among all gray levels.
• It is useful sometimes to be able to specify the shape of the histogram
that we wish the processed image to have. The method used to
generate a processed image that has a specified histogram is called
histogram matching or histogram specification.
Histogram Matching
Histogram Matching
Histogram matching (histogram specification)
— generate a processed image that has a specified
histogram
Histogram Matching
Histogram matching (histogram specification)
— generate a processed image that has a specified
histogram
Let pr (r ) and pz ( z ) denote the continous probability
density functions of the variables r and z. pz ( z ) is the
specified probability density function.
Let s be the random variable with the probability
r
s T ( r ) ( L 1) pr ( w) dw
0
1
z G ( s) G 1
T (r)
Histogram Matching: Procedure
Histogram Matching: Procedure
• Obtain pr(r) from the input image and then obtain the values of s
• Use the specified PDF and obtain the transformation function G(z)
• Mapping from s to z
Histogram Matching: Procedure
• Obtain pr(r) from the input image and then obtain the values of s
r
s ( L 1) pr (w)dw
0
• Use the specified PDF and obtain the transformation function G(z)
• Mapping from s to z
Histogram Matching: Procedure
• Obtain pr(r) from the input image and then obtain the values of s
r
s ( L 1) pr (w)dw
0
• Use the specified PDF and obtain the transformation function G(z)
• Mapping from s to z
Histogram Matching: Procedure
• Obtain pr(r) from the input image and then obtain the values of s
r
s ( L 1) pr (w)dw
0
• Use the specified PDF and obtain the transformation function G(z)
z
G( z) ( L 1) pz (t )dt s
0
• Mapping from s to z
Histogram Matching: Procedure
• Obtain pr(r) from the input image and then obtain the values of s
r
s ( L 1) pr (w)dw
0
• Use the specified PDF and obtain the transformation function G(z)
z
G( z) ( L 1) pz (t )dt s
0
• Mapping from s to z
Histogram Matching: Procedure
• Obtain pr(r) from the input image and then obtain the values of s
r
s ( L 1) pr (w)dw
0
• Use the specified PDF and obtain the transformation function G(z)
z
G( z) ( L 1) pz (t )dt s
0
• Mapping from s to z
1
z G ( s)
Histogram Matching: Example
Histogram Matching: Example
• Assuming continuous intensity values, suppose that an image has
the intensity PDF
0,
otherwise
• Find the transformation function that will produce an image
whose intensity PDF is
Histogram Matching: Example
• Assuming continuous intensity values, suppose that an image has
the intensity PDF
2r
, for 0 r L -1
pr (r ) ( L 1) 2
0,
otherwise
• Find the transformation function that will produce an image
whose intensity PDF is
Histogram Matching: Example
• Assuming continuous intensity values, suppose that an image has
the intensity PDF
2r
, for 0 r L -1
pr (r ) ( L 1) 2
0,
otherwise
• Find the transformation function that will produce an image
whose intensity PDF is
3z 2
, for 0 z ( L -1)
pz ( z ) ( L 1) 3
0,
otherwise
2r
, for 0 r L -1
pr (r ) ( L 1) 2
0,
otherwise
2r 3z 2
, for 0 r L -1 , for 0 z ( L -1)
pr (r ) ( L 1) 2
pz ( z ) ( L 1) 3
0, 0,
otherwise otherwise
Histogram Matching: Example
Histogram Matching: Example
• Use the specified PDF and obtain the transformation function G(zq), round
the value to the integer range [0, L-1].
• Mapping from sk to zq
Histogram Matching: Discrete Cases
• Obtain pr(rj) from the input image and then obtain the values of sk, round
the value to the integer range [0, L-1].
k
( L 1) k
sk T (rk ) ( L 1) pr (rj ) nj
j 0 MN j 0
• Use the specified PDF and obtain the transformation function G(zq), round
the value to the integer range [0, L-1].
• Mapping from sk to zq
Histogram Matching: Discrete Cases
• Obtain pr(rj) from the input image and then obtain the values of sk, round
the value to the integer range [0, L-1].
k
( L 1) k
sk T (rk ) ( L 1) pr (rj ) nj
j 0 MN j 0
• Use the specified PDF and obtain the transformation function G(zq), round
the value to the integer range [0, L-1].
• Mapping from sk to zq
Histogram Matching: Discrete Cases
• Obtain pr(rj) from the input image and then obtain the values of sk, round
the value to the integer range [0, L-1].
k
( L 1) k
sk T (rk ) ( L 1) pr (rj ) nj
j 0 MN j 0
• Use the specified PDF and obtain the transformation function G(zq), round
the value to the integer range [0, L-1].
q
G( zq ) ( L 1) pz ( zi ) sk
i 0
• Mapping from sk to zq
Histogram Matching: Discrete Cases
• Obtain pr(rj) from the input image and then obtain the values of sk, round
the value to the integer range [0, L-1].
k
( L 1) k
sk T (rk ) ( L 1) pr (rj ) nj
j 0 MN j 0
• Use the specified PDF and obtain the transformation function G(zq), round
the value to the integer range [0, L-1].
q
G( zq ) ( L 1) pz ( zi ) sk
i 0
• Mapping from sk to zq
Histogram Matching: Discrete Cases
• Obtain pr(rj) from the input image and then obtain the values of sk, round
the value to the integer range [0, L-1].
k
( L 1) k
sk T (rk ) ( L 1) pr (rj ) nj
j 0 MN j 0
• Use the specified PDF and obtain the transformation function G(zq), round
the value to the integer range [0, L-1].
q
G( zq ) ( L 1) pz ( zi ) sk
i 0
1
• Mapping from sk to zq
zq G (sk )
Example: Histogram Matching
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity distribution
shown in the following table (on the left). Get the histogram transformation function and make the
output image with the specified histogram, listed in the table on the right.
Step 1: To find scaled histogram equalized values ‘s’ for original image ‘r.’
Example: Histogram Matching
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity distribution
shown in the following table (on the left). Get the histogram transformation function and make the
output image with the specified histogram, listed in the table on the right.
Step 1: To find scaled histogram equalized values ‘s’ for original image ‘r.’
Gray Level
𝑟𝑘
r0 = 0
r1 = 1
r2 = 2
r3 = 3
r4 = 4
r5 = 5
r6 = 6
r7 = 7
Example: Histogram Matching
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity distribution
shown in the following table (on the left). Get the histogram transformation function and make the
output image with the specified histogram, listed in the table on the right.
Step 1: To find scaled histogram equalized values ‘s’ for original image ‘r.’
Gray Level 𝑛𝑘
𝑟𝑘
r0 = 0 790
r1 = 1 1023
r2 = 2 850
r3 = 3 656
r4 = 4 329
r5 = 5 245
r6 = 6 122
r7 = 7 81
Example: Histogram Matching
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity distribution
shown in the following table (on the left). Get the histogram transformation function and make the
output image with the specified histogram, listed in the table on the right.
Step 1: To find scaled histogram equalized values ‘s’ for original image ‘r.’
Step 1: To find scaled histogram equalized values ‘s’ for original image ‘r.’
𝑘
Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁
𝑟𝑘 PDF 𝐶𝐷𝐹 = 𝑝𝑟 𝑟𝑗
𝑗=0
Step 1: To find scaled histogram equalized values ‘s’ for original image ‘r.’
𝑘
Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹
𝑟𝑘 PDF 𝐶𝐷𝐹 = 𝑝𝑟 𝑟𝑗
𝑗=0
Step 1: To find scaled histogram equalized values ‘s’ for original image ‘r.’
𝑘
Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹 Gray Level
𝑟𝑘 PDF 𝐶𝐷𝐹 = 𝑝𝑟 𝑟𝑗 𝑠𝑘
𝑗=0
Step 1: To find scaled histogram equalized values ‘s’ for original image ‘r.’
𝑘
Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹 Gray Level 𝑛𝑘
𝑟𝑘 PDF 𝐶𝐷𝐹 = 𝑝𝑟 𝑟𝑗 𝑠𝑘
𝑗=0
Gray Level
𝑧𝑖
z0 = 0
z1 = 1
z2 = 2
z3 = 3
z4 = 4
z5 = 5
z6 = 6
z7 = 7
Example: Histogram Matching
Step 2: Compute all values of transformation function G(z) for the specified image
histogram. Let this specified image be ‘z’.
z0 = 0 0.00
z1 = 1 0.00
z2 = 2 0.00
z3 = 3 0.15
z4 = 4 0.20
z5 = 5 0.30
z6 = 6 0.20
z7 = 7 0.15
Example: Histogram Matching
Step 2: Compute all values of transformation function G(z) for the specified image
histogram. Let this specified image be ‘z’.
𝑖
Gray Level 𝑝𝑧 𝑧𝑖 = 𝑛𝑖 /𝑀𝑁
𝑧𝑖 PDF 𝐶𝐷𝐹 = 𝑝𝑧 𝑧𝑖
𝑗=0
z0 = 0 0.00 0.00
z1 = 1 0.00 0.00
z2 = 2 0.00 0.00
z3 = 3 0.15 0.15
z4 = 4 0.20 0.35
z5 = 5 0.30 0.65
z6 = 6 0.20 0.85
z7 = 7 0.15 1
Example: Histogram Matching
Step 2: Compute all values of transformation function G(z) for the specified image
histogram. Let this specified image be ‘z’.
𝑖
Gray Level 𝑝𝑧 𝑧𝑖 = 𝑛𝑖 /𝑀𝑁 𝐺(𝑧) = 𝐿 − 1 ∗ 𝐶𝐷𝐹
𝑧𝑖 PDF 𝐶𝐷𝐹 = 𝑝𝑧 𝑧𝑖
𝑗=0
𝑖
Gray Level 𝑝𝑧 𝑧𝑖 = 𝑛𝑖 /𝑀𝑁 𝐺(𝑧) = 𝐿 − 1 ∗ 𝐶𝐷𝐹 𝐺(𝑧)
𝑧𝑖 PDF 𝐶𝐷𝐹 = 𝑝𝑧 𝑧𝑖
𝑗=0
523
Example: Histogram Matching
Example: Histogram Matching
Figure 3.24
(a) An image, and (b) its histogram.
Figure 3.25
(a) Histogram equalization transformation obtained using the histogram in
Fig. 3.24(b). (b) Histogram equalized image. (c) Histogram of equalized image.
Figure 3.26
Histogram specification. (a) Specified histogram. (b) Transformation
G zq ,
labeled (1), and G sk , labeled (2). (c) Result of histogram specification. (d)
1
• Specified Image:
Gray 0 1 2 3 4 5 6 7
Level
No. of 0 0 0 0 10 20 22 12
Pixels
Example: Histogram Matching
Step 1: To find scaled histogram equalized values ‘s’ for original image
‘r.’
Example: Histogram Matching
Step 1: To find scaled histogram equalized values ‘s’ for original image
‘r.’
Gray Level
𝑟𝑘
r0 = 0
r1 = 1
r2 = 2
r3 = 3
r4 = 4
r5 = 5
r6 = 6
r7 = 7
Example: Histogram Matching
Step 1: To find scaled histogram equalized values ‘s’ for original image
‘r.’
Gray Level 𝑛𝑘
𝑟𝑘
r0 = 0 6
r1 = 1 4
r2 = 2 5
r3 = 3 7
r4 = 4 8
r5 = 5 10
r6 = 6 12
r7 = 7 12
Example: Histogram Matching
Step 1: To find scaled histogram equalized values ‘s’ for original image
‘r.’
r0 = 0 6 6/64 = 0.094
r1 = 1 4 0.0625
r2 = 2 5 0.0781
r3 = 3 7 0.109
r4 = 4 8 0.125
r5 = 5 10 0.156
r6 = 6 12 0.1875
r7 = 7 12 0.1875
Example: Histogram Matching
Step 1: To find scaled histogram equalized values ‘s’ for original image
‘r.’
𝑘
Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁
𝑟𝑘 PDF 𝐶𝐷𝐹 = 𝑝𝑟 𝑟𝑗
𝑗=0
Step 1: To find scaled histogram equalized values ‘s’ for original image
‘r.’
𝑘
Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹
𝑟𝑘 PDF 𝐶𝐷𝐹 = 𝑝𝑟 𝑟𝑗
𝑗=0
Step 1: To find scaled histogram equalized values ‘s’ for original image
‘r.’
𝑘
Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹 Gray Level
𝑟𝑘 PDF 𝐶𝐷𝐹 = 𝑝𝑟 𝑟𝑗 𝑠𝑘
𝑗=0
539
Example: Histogram Matching
Step 2: Compute all values of transformation function G(z) for the specified image
histogram. Let this specified image be ‘z’.
Gray Level
𝑧𝑖
z0 = 0
z1 = 1
z2 = 2
z3 = 3
z4 = 4
z5 = 5
z6 = 6
z7 = 7
540
Example: Histogram Matching
Step 2: Compute all values of transformation function G(z) for the specified image
histogram. Let this specified image be ‘z’.
Gray Level 𝑛𝑘
𝑧𝑖
z0 = 0 0
z1 = 1 0
z2 = 2 0
z3 = 3 0
z4 = 4 10
z5 = 5 20
z6 = 6 22
z7 = 7 12
541
Example: Histogram Matching
Step 2: Compute all values of transformation function G(z) for the specified image
histogram. Let this specified image be ‘z’.
z0 = 0 0 0.00
z1 = 1 0 0.00
z2 = 2 0 0.00
z3 = 3 0 0.00
z4 = 4 10 0.156
z5 = 5 20 0.3125
z6 = 6 22 0.3438
z7 = 7 12 0.1875
542
Example: Histogram Matching
Step 2: Compute all values of transformation function G(z) for the specified image
histogram. Let this specified image be ‘z’.
𝑛𝑘 𝑖
Gray Level 𝑝𝑧 𝑧𝑖 = 𝑛𝑖 /𝑀𝑁
𝑧𝑖 PDF 𝐶𝐷𝐹 = 𝑝𝑧 𝑧𝑖
𝑗=0
z0 = 0 0 0.00 0.00
z1 = 1 0 0.00 0.00
z2 = 2 0 0.00 0.00
z3 = 3 0 0.00 0.00
z4 = 4 10 0.156 0.156
z5 = 5 20 0.3125 0.4685
z6 = 6 22 0.3438 0.8123
z7 = 7 12 0.1875 0.9998
543
Example: Histogram Matching
Step 2: Compute all values of transformation function G(z) for the specified image
histogram. Let this specified image be ‘z’.
𝑛𝑘 𝑖
Gray Level 𝑝𝑧 𝑧𝑖 = 𝑛𝑖 /𝑀𝑁 𝐺(𝑧) = 𝐿 − 1 ∗ 𝐶𝐷𝐹
𝑧𝑖 PDF 𝐶𝐷𝐹 = 𝑝𝑧 𝑧𝑖
𝑗=0
544
Example: Histogram Matching
Step 2: Compute all values of transformation function G(z) for the specified image
histogram. Let this specified image be ‘z’.
𝑛𝑘 𝑖
Gray Level 𝑝𝑧 𝑧𝑖 = 𝑛𝑖 /𝑀𝑁 𝐺(𝑧) = 𝐿 − 1 ∗ 𝐶𝐷𝐹 𝐺(𝑧)
𝑧𝑖 PDF 𝐶𝐷𝐹 = 𝑝𝑧 𝑧𝑖
𝑗=0
545
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level
𝑟𝑘
r0 = 0
r1 = 1
r2 = 2
r3 = 3
r4 = 4
r5 = 5
r6 = 6
r7 = 7
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1
r1 = 1 s1 = 1
r2 = 2 s2 = 2
r3 = 3 s3 = 2
r4 = 4 s4 = 3
r5 = 5 s5 = 4
r6 = 6 s6 = 6
r7 = 7 s7 = 7
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝐺(𝑧)
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1 0
r1 = 1 s1 = 1 0
r2 = 2 s2 = 2 0
r3 = 3 s3 = 2 0
r4 = 4 s4 = 3 1
r5 = 5 s5 = 4 3
r6 = 6 s6 = 6 6
r7 = 7 s7 = 7 7
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝐺(𝑧) 𝑧𝑞
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1 0 4
r1 = 1 s1 = 1 0 4
r2 = 2 s2 = 2 0 4
r3 = 3 s3 = 2 0 4
r4 = 4 s4 = 3 1 5
r5 = 5 s5 = 4 3 5
r6 = 6 s6 = 6 6 6
r7 = 7 s7 = 7 7 7
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝐺(𝑧) 𝑧𝑞
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1 0 4
r1 = 1 s1 = 1 0 4
r2 = 2 s2 = 2 0 4
r3 = 3 s3 = 2 0 4
r4 = 4 s4 = 3 1 5
r5 = 5 s5 = 4 3 5
r6 = 6 s6 = 6 6 6
r7 = 7 s7 = 7 7 7
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝐺(𝑧) 𝑧𝑞 𝑛𝑞
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1 0 4 22
r1 = 1 s1 = 1 0 4
r2 = 2 s2 = 2 0 4
r3 = 3 s3 = 2 0 4
r4 = 4 s4 = 3 1 5 18
r5 = 5 s5 = 4 3 5
r6 = 6 s6 = 6 6 6 12
r7 = 7 s7 = 7 7 7 12
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝐺(𝑧) 𝑧𝑞 𝑛𝑞 𝑧𝑞
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1 0 4 22 4
r1 = 1 s1 = 1 0 4 4
r2 = 2 s2 = 2 0 4 5
r3 = 3 s3 = 2 0 4 5
r4 = 4 s4 = 3 1 5 18 5
r5 = 5 s5 = 4 3 5 5
r6 = 6 s6 = 6 6 6 12 6
r7 = 7 s7 = 7 7 7 12 7
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝐺(𝑧) 𝑧𝑞 𝑛𝑞 𝑧𝑞
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1 0 4 22 4
r1 = 1 s1 = 1 0 4 4
r2 = 2 s2 = 2 0 4 5
r3 = 3 s3 = 2 0 4 5
r4 = 4 s4 = 3 1 5 18 5
r5 = 5 s5 = 4 3 5 5
r6 = 6 s6 = 6 6 6 12 6
r7 = 7 s7 = 7 7 7 12 7
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝐺(𝑧) 𝑧𝑞 𝑛𝑞 𝑧𝑞 𝑛𝑞
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1 0 4 22 4 10
r1 = 1 s1 = 1 0 4 4
r2 = 2 s2 = 2 0 4 5 30
r3 = 3 s3 = 2 0 4 5
r4 = 4 s4 = 3 1 5 18 5
r5 = 5 s5 = 4 3 5 5
r6 = 6 s6 = 6 6 6 12 6 12
r7 = 7 s7 = 7 7 7 12 7 12
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝐺(𝑧) 𝑧𝑞 𝑛𝑞 𝑧𝑞 𝑛𝑞
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1 0 4 22 4 10
r1 = 1 s1 = 1 0 4 4
r2 = 2 s2 = 2 0 4 5 30
r3 = 3 s3 = 2 0 4 5
r4 = 4 s4 = 3 1 5 18 5
r5 = 5 s5 = 4 3 5 5
r6 = 6 s6 = 6 6 6 12 6 12
r7 = 7 s7 = 7 7 7 12 7 12
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
Gray Level Gray Level
𝐺(𝑧) 𝑧𝑞 𝑛𝑞 𝑧𝑞 𝑛𝑞 Gray
𝑟𝑘 𝑠𝑘 Level
𝑟𝑘
r0 = 0 s0 = 1 0 4 22 4 10
r0 = 0
r1 = 1 s1 = 1 0 4 4
r1 = 1
r2 = 2 s2 = 2 0 4 5 30
r2 = 2
r3 = 3 s3 = 2 0 4 5
r3 = 3
r4 = 4 s4 = 3 1 5 18 5
r4 = 4
r5 = 5 s5 = 4 3 5 5
r5 = 5
r6 = 6 s6 = 6 6 6 12 6 12
r6 = 6
r7 = 7 s7 = 7 7 7 12 7 12
r7 = 7
Histogram Matching - Example
• Step 3: Create mappings from s to z : We find the value of zq so that the
value of G(z) is closest to sk
𝑛𝑞 𝑛𝑞 𝑛𝑘
Gray Level Gray Level
𝐺(𝑧) 𝑧𝑞 𝑧𝑞 Gray
𝑟𝑘 𝑠𝑘 Level
𝑟𝑘
r0 = 0 s0 = 1 0 4 22 4 10
r0 = 0 6
r1 = 1 s1 = 1 0 4 4
r1 = 1 4
r2 = 2 s2 = 2 0 4 5 30
r2 = 2 5
r3 = 3 s3 = 2 0 4 5
r3 = 3 7
r4 = 4 s4 = 3 1 5 18 5
r4 = 4 8
r5 = 5 s5 = 4 3 5 5
r5 = 5 10
r6 = 6 s6 = 6 6 6 12 6 12
r6 = 6 12
r7 = 7 s7 = 7 7 7 12 7 12
r7 = 7 12
Local Histogram Processing
• Define a neighborhood and move its center from pixel to pixel.
L 1
m ri p(ri )
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1
m ri p(ri )
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1
m ri p(ri )
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1
m ri p(ri )
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1
m ri p(ri )
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1
m ri p(ri )
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1
m ri p(ri )
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1
m ri p(ri )
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1 M 1 N 1
m ri p(ri )
1
MN
f ( x, y )
x 0 y 0
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1 M 1 N 1
m ri p(ri )
1
MN
f ( x, y )
x 0 y 0
i 0
L 1
2 u2 (r ) (ri m) 2 p(ri )
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1 M 1 N 1
m ri p(ri )
1
MN
f ( x, y )
x 0 y 0
i 0
L 1 M 1 N 1
u2 (r ) (ri m) p(ri )
1
f ( x, y ) m
2 2 2
MN x 0 y 0
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1 M 1 N 1
m ri p(ri )
1
MN
f ( x, y )
x 0 y 0
i 0
Variance
L 1 M 1 N 1
u2 (r ) (ri m) p(ri )
1
f ( x, y ) m
2 2 2
MN x 0 y 0
i 0
Using Histogram Statistics for Image Enhancement
Average Intensity
L 1 M 1 N 1
m ri p(ri )
1
MN
f ( x, y )
x 0 y 0
i 0
L 1
un (r ) (ri m) p(ri )
n
i 0
Variance
L 1 M 1 N 1
u2 (r ) (ri m) p(ri )
1
f ( x, y ) m
2 2 2
MN x 0 y 0
i 0
Using Histogram Statistics for Image Enhancement
Using Histogram Statistics for Image Enhancement
• Global mean and variance are measured over entire image. Used for gross
adjustment of overall intensity and variance.
• Local mean and variance are measured locally. Used for local adjustment of intensity
and contrast.
• (x, y) Co-ordinates of pixel.
• 𝑆𝑥𝑦 : neighbourhood (sub image), centered on (x, y).
• 𝑟0 … . . 𝑟𝐿−1 : possible intensity values.
• 𝑝𝑠𝑥𝑦 : Histogram of pixels in the region 𝑆𝑥𝑦
Using Histogram Statistics for Image Enhancement
• Global mean and variance are measured over entire image. Used for gross
adjustment of overall intensity and variance.
• Local mean and variance are measured locally. Used for local adjustment of intensity
and contrast.
• (x, y) Co-ordinates of pixel.
• 𝑆𝑥𝑦 : neighbourhood (sub image), centered on (x, y).
• 𝑟0 … . . 𝑟𝐿−1 : possible intensity values.
• 𝑝𝑠𝑥𝑦 : Histogram of pixels in the region 𝑆𝑥𝑦
Using Histogram Statistics for Image Enhancement
• Global mean and variance are measured over entire image. Used for gross
adjustment of overall intensity and variance.
• Local mean and variance are measured locally. Used for local adjustment of intensity
and contrast.
• (x, y) Co-ordinates of pixel.
• 𝑆𝑥𝑦 : neighbourhood (sub image), centered on (x, y).
• 𝑟0 … . . 𝑟𝐿−1 : possible intensity values.
• 𝑝𝑠𝑥𝑦 : Histogram of pixels in the region 𝑆𝑥𝑦
Using Histogram Statistics for Image Enhancement
• Global mean and variance are measured over entire image. Used for gross
adjustment of overall intensity and variance.
• Local mean and variance are measured locally. Used for local adjustment of intensity
and contrast.
• (x, y) Co-ordinates of pixel.
• 𝑆𝑥𝑦 : neighbourhood (sub image), centered on (x, y).
• 𝑟0 … . . 𝑟𝐿−1 : possible intensity values.
• 𝑝𝑠𝑥𝑦 : Histogram of pixels in the region 𝑆𝑥𝑦
Using Histogram Statistics for Image Enhancement
• Global mean and variance are measured over entire image. Used for gross
adjustment of overall intensity and variance.
• Local mean and variance are measured locally. Used for local adjustment of intensity
and contrast.
• (x, y) Co-ordinates of pixel.
• 𝑆𝑥𝑦 : neighbourhood (sub image), centered on (x, y).
• 𝑟0 … . . 𝑟𝐿−1 : possible intensity values.
• 𝑝𝑠𝑥𝑦 : Histogram of pixels in the region 𝑆𝑥𝑦
Using Histogram Statistics for Image Enhancement
• Global mean and variance are measured over entire image. Used for gross
adjustment of overall intensity and variance.
• Local mean and variance are measured locally. Used for local adjustment of intensity
and contrast.
• (x, y) Co-ordinates of pixel.
• 𝑆𝑥𝑦 : neighbourhood (sub image), centered on (x, y).
• 𝑟0 … . . 𝑟𝐿−1 : possible intensity values.
• 𝑝𝑠𝑥𝑦 : Histogram of pixels in the region 𝑆𝑥𝑦
Using Histogram Statistics for Image Enhancement
• Global mean and variance are measured over entire image. Used for gross
adjustment of overall intensity and variance.
• Local mean and variance are measured locally. Used for local adjustment of intensity
and contrast.
• (x, y) Co-ordinates of pixel.
• 𝑆𝑥𝑦 : neighbourhood (sub image), centered on (x, y).
• 𝑟0 … . . 𝑟𝐿−1 : possible intensity values.
• 𝑝𝑠𝑥𝑦 : Histogram of pixels in the region 𝑆𝑥𝑦