0% found this document useful (0 votes)
43 views482 pages

Lectures 1-4 (Intensity Transformations)

The document discusses the topics of intensity transformation and spatial filtering that will be covered in the first four lectures of a digital image processing course. It lists recommended textbooks and the chapters covered. It defines digital image processing as the manipulation of digital images through a computer. Key topics covered include intensity transformations, spatial filtering, frequency domain filtering, image restoration, compression, morphological processing, and segmentation. Basic terminology like pixel, intensity, brightness, contrast, and resolution are also introduced. Notational conventions for intensity transformations are provided.

Uploaded by

explore.world512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views482 pages

Lectures 1-4 (Intensity Transformations)

The document discusses the topics of intensity transformation and spatial filtering that will be covered in the first four lectures of a digital image processing course. It lists recommended textbooks and the chapters covered. It defines digital image processing as the manipulation of digital images through a computer. Key topics covered include intensity transformations, spatial filtering, frequency domain filtering, image restoration, compression, morphological processing, and segmentation. Basic terminology like pixel, intensity, brightness, contrast, and resolution are also introduced. Notational conventions for intensity transformations are provided.

Uploaded by

explore.world512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 482

INTENSITY TRANSFORMATION &

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.

• Image Processing  Artificial Intelligence  Computer Vision

• No Clear cut boundaries.

• One useful paradigm for distinction


• Low – level processes (reduce noise, contrast enhancement and image
sharpening)
• Mid – level processes (image segmentation, description and classification)
• High – level processes (making sense , image analysis and performing
cognitive functions)
What is DIP ?
• Digital image processing deals with the manipulation of digital images through a
digital computer.

• Image Processing  Artificial Intelligence  Computer Vision

• No Clear cut boundaries.

• One useful paradigm for distinction


• Low – level processes (reduce noise, contrast enhancement and image
sharpening)
• Mid – level processes (image segmentation, description and classification)
• High – level processes (making sense , image analysis and performing
cognitive functions)
What is DIP ?
• Digital image processing deals with the manipulation of digital images through a
digital computer.

• Image Processing  Artificial Intelligence  Computer Vision

• No Clear cut boundaries.

• One useful paradigm for distinction


• Low – level processes (reduce noise, contrast enhancement and image
sharpening)
• Mid – level processes (image segmentation, description and classification)
• High – level processes (making sense , image analysis and performing
cognitive functions)
What is DIP ?
• Digital image processing deals with the manipulation of digital images through a
digital computer.

• Image Processing  Artificial Intelligence  Computer Vision

• No Clear cut boundaries.

• One useful paradigm for distinction


• Low – level processes (reduce noise, contrast enhancement and image
sharpening)
• Mid – level processes (image segmentation, description and classification)
• High – level processes (making sense , image analysis and performing
cognitive functions)
What is DIP ?
• Digital image processing deals with the manipulation of digital images through a
digital computer.

• Image Processing  Artificial Intelligence  Computer Vision

• No Clear cut boundaries.

• One useful paradigm for distinction


• Low – level processes (reduce noise, contrast enhancement and image
sharpening)
• Mid – level processes (image segmentation, description and classification)
• High – level processes (making sense , image analysis and performing
cognitive functions)
What is DIP ?
• Digital image processing deals with the manipulation of digital images through a
digital computer.

• Image Processing  Artificial Intelligence  Computer Vision

• No Clear cut boundaries.

• One useful paradigm for distinction


• Low – level processes (reduce noise, contrast enhancement and image
sharpening)
• Mid – level processes (image segmentation, description and classification)
• High – level processes (making sense , image analysis and performing
cognitive functions)
What is DIP ?
• Digital image processing deals with the manipulation of digital images through a
digital computer.

• Image Processing  Artificial Intelligence  Computer Vision

• No Clear cut boundaries.

• One useful paradigm for distinction


• Low – level processes (reduce noise, contrast enhancement and image
sharpening)
• Mid – level processes (image segmentation, description and classification)
• High – level processes (making sense , image analysis and performing
cognitive functions)
Example of scope of DIP
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.
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

It refers to the number of pixels in an image. Sometimes identified by


• Resolution the width and height of the image.
Eg: 2048 x 1536 contains 3145728 pixels or 3.1 Megapixels.
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

Contrast stretching is a process that expands the range of intensity


levels in an image so that it spans the available full intensity range.
Contrast Stretching
• (r1, s1) and (r2, s2) control the shape of
transformation.
• What if r1 = r2, s1 = 0 and s2 = L -1??
• It’s Thresholding Function.
• What if (r1, s1) = (rmin , 0) and (r2, s2) =
(rmax , L - 1) ??
• It’s Contrast Stretching.

Contrast stretching is a process that expands the range of intensity


levels in an image so that it spans the available full intensity range.
Contrast Stretching
• (r1, s1) and (r2, s2) control the shape of
transformation.
• What if r1 = r2, s1 = 0 and s2 = L -1??
• It’s Thresholding Function.
• What if (r1, s1) = (rmin , 0) and (r2, s2) =
(rmax , L - 1) ??
• It’s Contrast Stretching.

Contrast stretching is a process that expands the range of intensity


levels in an image so that it spans the available full intensity range.
Contrast Stretching
• (r1, s1) and (r2, s2) control the shape of
transformation.
• What if r1 = r2, s1 = 0 and s2 = L -1??
• It’s Thresholding Function.
• What if (r1, s1) = (rmin , 0) and (r2, s2) =
(rmax , L - 1) ??
• It’s Contrast Stretching.

Contrast stretching is a process that expands the range of intensity


levels in an image so that it spans the available full intensity range.
Contrast Stretching
• (r1, s1) and (r2, s2) control the shape of
transformation.
• What if r1 = r2, s1 = 0 and s2 = L -1??
• It’s Thresholding Function.
• What if (r1, s1) = (rmin , 0) and (r2, s2) =
(rmax , L - 1) ??
• It’s Contrast Stretching.

Contrast stretching is a process that expands the range of intensity


levels in an image so that it spans the available full intensity range.
Contrast Stretching
• (r1, s1) and (r2, s2) control the shape of
transformation.
• What if r1 = r2, s1 = 0 and s2 = L -1??
• It’s Thresholding Function.
• What if (r1, s1) = (rmin , 0) and (r2, s2) =
(rmax , L - 1) ??
• It’s Contrast Stretching.

Contrast stretching is a process that expands the range of intensity


levels in an image so that it spans the available full intensity range.
Contrast Stretching
• (r1, s1) and (r2, s2) control the shape of
transformation.
• What if r1 = r2, s1 = 0 and s2 = L -1??
• It’s Thresholding Function.
• What if (r1, s1) = (rmin , 0) and (r2, s2) =
(rmax , L - 1) ??
• It’s Contrast Stretching.

Contrast stretching is a process that expands the range of intensity


levels in an image so that it spans the available full intensity range.
Contrast Stretching
• (r1, s1) and (r2, s2) control the shape of
transformation.
• What if r1 = r2, s1 = 0 and s2 = L -1??
• It’s Thresholding Function.
• What if (r1, s1) = (rmin , 0) and (r2, s2) =
(rmax , L - 1) ??
• It’s Contrast Stretching.

Contrast stretching is a process that expands the range of intensity


levels in an image so that it spans the available full intensity range.
Contrast Stretching
• (r1, s1) and (r2, s2) control the shape of
transformation.
• What if r1 = r2, s1 = 0 and s2 = L -1??
• It’s Thresholding Function.
• What if (r1, s1) = (rmin , 0) and (r2, s2) =
(rmax , L - 1) ??
• It’s Contrast Stretching.

Contrast stretching is a process that expands the range of intensity


levels in an image so that it spans the available full intensity range.
Contrast Stretching (Numerical)
Contrast Stretching (Numerical)
7 12 8
16 9 6
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1

102 187 119


255 136 85
153 238 0
Contrast Stretching (Numerical)
7 12 8
 Original Image
16 9 6  Perform Contrast Stretching on this image such that the lowest gray level is
mapped to 0 and highest to 255
10 15 1

102 187 119


255 136 85
153 238 0
Piecewise Linear Transformation or CS
(Numerical)
Piecewise Linear Transformation or CS
(Numerical)
4 3 5 2
3 6 4 6
2 2 6 5
7 6 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
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
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
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
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
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
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
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
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
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
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
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
Piecewise Linear Transformation or CS
(Numerical)
Piecewise Linear Transformation or CS
(Numerical)
4 3 5 2
3 6 4 6
2 2 6 5
7 6 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
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
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
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
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
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
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
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

Bit Planes 8, 7 & 6

Original Image

Bit Planes 8, 7, 6 & 5


Bit Planes 8 & 7

Bit Planes 8, 7 & 6

Original Image

Bit Planes 8, 7, 6 & 5


Bit Planes 8 & 7

Bit Planes 8, 7 & 6

Original Image

Bit Planes 8, 7, 6 & 5


Bit Planes 8 & 7

Bit Planes 8, 7 & 6

Original Image

Bit Planes 8, 7, 6 & 5


Image Histogram
Image Histogram
• A histogram is a graph that shows frequency of the desired element. Usually
histogram have bars that represent frequency of occurring data in the whole data
set.
• A histogram has two axis, the x axis contains the event whose frequency we have
to count and y contains the respective frequency.
• An image histogram is a plot of the gray- level frequencies. (i.e., the number of
pixels in the image that have a particular gray level.)
Image Histogram
• A histogram is a graph that shows frequency of the desired element. Usually
histogram have bars that represent frequency of occurring data in the whole data
set.
• A histogram has two axis, the x axis contains the event whose frequency we have
to count and y contains the respective frequency.
• An image histogram is a plot of the gray- level frequencies. (i.e., the number of
pixels in the image that have a particular gray level.)
Image Histogram
• A histogram is a graph that shows frequency of the desired element. Usually
histogram have bars that represent frequency of occurring data in the whole data
set.
• A histogram has two axis, the x axis contains the event whose frequency we have
to count and y contains the respective frequency.
• An image histogram is a plot of the gray- level frequencies. (i.e., the number of
pixels in the image that have a particular gray level.)
Image Histogram
• A histogram is a graph that shows frequency of the desired element. Usually
histogram have bars that represent frequency of occurring data in the whole data
set.
• A histogram has two axis, the x axis contains the event whose frequency we have
to count and y contains the respective frequency.
• An image histogram is a plot of the gray- level frequencies. (i.e., the number of
pixels in the image that have a particular gray level.)
Histogram Processing
Histogram Processing
• Histogram manipulation can be used for image enhancement.
• Information inherent in histogram is also useful in other image
processing applications, such as image compression and segmentation.
• Histogram Equalization:
• To improve the contrast of an image.
• To transform an image in such a way that the transformed image has
nearly uniform distribution of pixel values.
Histogram Processing
• Histogram manipulation can be used for image enhancement.
• Information inherent in histogram is also useful in other image
processing applications, such as image compression and segmentation.
• Histogram Equalization:
• To improve the contrast of an image.
• To transform an image in such a way that the transformed image has
nearly uniform distribution of pixel values.
Histogram Processing
• Histogram manipulation can be used for image enhancement.
• Information inherent in histogram is also useful in other image
processing applications, such as image compression and segmentation.
• Histogram Equalization:
• To improve the contrast of an image.
• To transform an image in such a way that the transformed image has
nearly uniform distribution of pixel values.
Histogram Processing
• Histogram manipulation can be used for image enhancement.
• Information inherent in histogram is also useful in other image
processing applications, such as image compression and segmentation.
• Histogram Equalization:
• To improve the contrast of an image.
• To transform an image in such a way that the transformed image has
nearly uniform distribution of pixel values.
Histogram Processing
• Histogram manipulation can be used for image enhancement.
• Information inherent in histogram is also useful in other image
processing applications, such as image compression and segmentation.
• Histogram Equalization:
• To improve the contrast of an image.
• To transform an image in such a way that the transformed image has
nearly uniform distribution of pixel values.
Histogram Equalization
Histogram Equalization
Histogram Equalization
Histogram Equalization
Histogram Equalization
Histogram Equalization
Histogram Equalization
• Intensity Mapping form

• Conditions:

• In some formulations to be discussed later, we use the inverse

in which case we change condition (a) to


Histogram Equalization
• Intensity Mapping form

• Conditions:

• In some formulations to be discussed later, we use the inverse

in which case we change condition (a) to


Histogram Equalization
• Intensity Mapping form

• Conditions:

• In some formulations to be discussed later, we use the inverse

in which case we change condition (a) to


Histogram Equalization
• Intensity Mapping form

• Conditions:

• In some formulations to be discussed later, we use the inverse

in which case we change condition (a) to


Histogram Equalization
• Intensity Mapping form

• Conditions:

• In some formulations to be discussed later, we use the inverse

in which case we change condition (a) to


Histogram Equalization
• Intensity Mapping form

• Conditions:

• In some formulations to be discussed later, we use the inverse

in which case we change condition (a) to


Histogram Equalization
• Intensity Mapping form

• Conditions:

• In some formulations to be discussed later, we use the inverse

in which case we change condition (a) to


Histogram Equalization
• Intensity Mapping form

• Conditions:

• In some formulations to be discussed later, we use the inverse

in which case we change condition (a) to


• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• A fundamental descriptor of a random variable is its PDF.
• Let 𝑝𝑟 (𝑟) and 𝑝𝑠 (𝑠) denote the PDFs of r and s, respectively.
• A fundamental result from basic probability theory is that if 𝑝𝑟 (𝑟) and
T(r) are known, and T(r) is continuous and differentiable over the
range of values of interest, then PDF of the transformed (mapped)
variable s can be obtained using the simple formula

• Consider the following transform function :

Where w is a dummy variable of integration and the right side of the


equation is CDF of random variable r.
• Does it satisfy condition a) and b)?
• To find the 𝑝𝑠 (𝑠) corresponding to the transformation function just
discussed we use eq. (3).
We know from Leibniz’s rule that the derivative of a definite integral
w.r.t its upper limit is simply the integrand evaluated at that limit.
• To find the 𝑝𝑠 (𝑠) corresponding to the transformation function just
discussed we use eq. (3).
We know from Leibniz’s rule that the derivative of a definite integral
w.r.t its upper limit is simply the integrand evaluated at that limit.
• To find the 𝑝𝑠 (𝑠) corresponding to the transformation function just
discussed we use eq. (3).
We know from Leibniz’s rule that the derivative of a definite integral
w.r.t its upper limit is simply the integrand evaluated at that limit.
• To find the 𝑝𝑠 (𝑠) corresponding to the transformation function just
discussed we use eq. (3).
We know from Leibniz’s rule that the derivative of a definite integral
w.r.t its upper limit is simply the integrand evaluated at that limit.
• To find the 𝑝𝑠 (𝑠) corresponding to the transformation function just
discussed we use eq. (3).
We know from Leibniz’s rule that the derivative of a definite integral
w.r.t its upper limit is simply the integrand evaluated at that limit.
• To find the 𝑝𝑠 (𝑠) corresponding to the transformation function just
discussed we use eq. (3).
We know from Leibniz’s rule that the derivative of a definite integral
w.r.t its upper limit is simply the integrand evaluated at that limit.
• To find the 𝑝𝑠 (𝑠) corresponding to the transformation function just
discussed we use eq. (3).
We know from Leibniz’s rule that the derivative of a definite integral
w.r.t its upper limit is simply the integrand evaluated at that limit.
• To find the 𝑝𝑠 (𝑠) corresponding to the transformation function just
discussed we use eq. (3).
We know from Leibniz’s rule that the derivative of a definite integral
w.r.t its upper limit is simply the integrand evaluated at that limit.
Example
Example
Example
• For discreet values,
• For discreet values,
• For discreet values,
• For discreet values,
Histogram Equalization Numerical
Figure 3.22
(a) Image from Phoenix Lander. (b) Result of histogram equalization. (c)
Histogram of image (a). (d) Histogram of image (b). (Original image
courtesy of NASA.)
Question
Question
Is histogram equalization always good?

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

Define a random variable z with the probability


z
G ( z )  ( L  1)  pz (t ) dt  s
0
Histogram Matching
Histogram Matching
r
s  T (r )  ( L  1)  pr ( w)dw
0
z
G ( z )  ( L  1)  pz (t )dt  s
0
Histogram Matching
r
s  T (r )  ( L  1)  pr ( w)dw
0
z
G ( z )  ( L  1)  pz (t )dt  s
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

• 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
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

• Find the histogram equalization transformation for the input image

• Find the histogram equalization transformation for the specified


histogram

• The transformation function


Histogram Matching: Example

• Find the histogram equalization transformation for the input image


r r 2w
s  T (r )  ( L  1)  pr ( w)dw  ( L  1)  dw
0 0 ( L  1) 2

• Find the histogram equalization transformation for the specified


histogram

• The transformation function


Histogram Matching: Example

• Find the histogram equalization transformation for the input image


r r 2w r2
s  T (r )  ( L  1)  pr ( w)dw  ( L  1)  dw 
0 0 ( L  1) 2
L 1
• Find the histogram equalization transformation for the specified
histogram

• The transformation function


Histogram Matching: Example

• Find the histogram equalization transformation for the input image


r r 2w r2
s  T (r )  ( L  1)  pr ( w)dw  ( L  1)  dw 
0 0 ( L  1) 2
L 1
• Find the histogram equalization transformation for the specified
histogram

• The transformation function


Histogram Matching: Example

• Find the histogram equalization transformation for the input image


r r 2w r2
s  T (r )  ( L  1)  pr ( w)dw  ( L  1)  dw 
0 0 ( L  1) 2
L 1
• Find the histogram equalization transformation for the specified
histogram
2 3
z z 3t z
G ( z )  ( L  1)  pz (t )dt  ( L  1)  dt  s
0 0 ( L  1) 3
( L  1) 2

• The transformation function


Histogram Matching: Example

• Find the histogram equalization transformation for the input image


r r 2w r2
s  T (r )  ( L  1)  pr ( w)dw  ( L  1)  dw 
0 0 ( L  1) 2
L 1
• Find the histogram equalization transformation for the specified
histogram
2 3
z z 3t z
G ( z )  ( L  1)  pz (t )dt  ( L  1)  dt  s
0 0 ( L  1) 3
( L  1) 2

• The transformation function


Histogram Matching: Example

• Find the histogram equalization transformation for the input image


r r 2w r2
s  T (r )  ( L  1)  pr ( w)dw  ( L  1)  dw 
0 0 ( L  1) 2
L 1
• Find the histogram equalization transformation for the specified
histogram
2 3
z z 3t z
G ( z )  ( L  1)  pz (t )dt  ( L  1)  dt  s
0 0 ( L  1) 3
( L  1) 2

• The transformation function


1/3
1/3  2 r  2
2 1/3
z  ( L  1) s 
2
 ( L  1)   ( L  1)r 
 L  1
Histogram Matching: Discrete Cases
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].

• 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.’

Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁


𝑟𝑘 PDF

r0 = 0 790 790/4096 = 0.19


r1 = 1 1023 1023/4096 = 0.25
r2 = 2 850 850/4096 = 0.21
r3 = 3 656 656/4096 = 0.16
r4 = 4 329 329/4096 = 0.08
r5 = 5 245 245/4096 = 0.06
r6 = 6 122 122/4096 = 0.03
r7 = 7 81 81/4096 = 0.02
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 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁
𝑟𝑘 PDF 𝐶𝐷𝐹 = ෍ 𝑝𝑟 𝑟𝑗
𝑗=0

r0 = 0 790 790/4096 = 0.19 0.19


r1 = 1 1023 1023/4096 = 0.25 0.44
r2 = 2 850 850/4096 = 0.21 0.65
r3 = 3 656 656/4096 = 0.16 0.81
r4 = 4 329 329/4096 = 0.08 0.89
r5 = 5 245 245/4096 = 0.06 0.95
r6 = 6 122 122/4096 = 0.03 0.98
r7 = 7 81 81/4096 = 0.02 1
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 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹
𝑟𝑘 PDF 𝐶𝐷𝐹 = ෍ 𝑝𝑟 𝑟𝑗
𝑗=0

r0 = 0 790 790/4096 = 0.19 0.19 7 x 0.19 = 1.33


r1 = 1 1023 1023/4096 = 0.25 0.44 7 x 0.44 = 3.08
r2 = 2 850 850/4096 = 0.21 0.65 7 x 0.65 = 4.55
r3 = 3 656 656/4096 = 0.16 0.81 7 x 0.81 = 5.67
r4 = 4 329 329/4096 = 0.08 0.89 7 x 0.89 = 6.23
r5 = 5 245 245/4096 = 0.06 0.95 7 x 0.95 = 6.65
r6 = 6 122 122/4096 = 0.03 0.98 7 x 0.98 = 6.86
r7 = 7 81 81/4096 = 0.02 1 7x1=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 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹 Gray Level
𝑟𝑘 PDF 𝐶𝐷𝐹 = ෍ 𝑝𝑟 𝑟𝑗 𝑠𝑘
𝑗=0

r0 = 0 790 790/4096 = 0.19 0.19 7 x 0.19 = 1.33 s0 = 1


r1 = 1 1023 1023/4096 = 0.25 0.44 7 x 0.44 = 3.08 s1 = 3
r2 = 2 850 850/4096 = 0.21 0.65 7 x 0.65 = 4.55 s2 = 5
r3 = 3 656 656/4096 = 0.16 0.81 7 x 0.81 = 5.67 s3 = 6
r4 = 4 329 329/4096 = 0.08 0.89 7 x 0.89 = 6.23 s4 = 6
r5 = 5 245 245/4096 = 0.06 0.95 7 x 0.95 = 6.65 s5 = 7
r6 = 6 122 122/4096 = 0.03 0.98 7 x 0.98 = 6.86 s6 = 7
r7 = 7 81 81/4096 = 0.02 1 7x1=7 s7 = 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 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹 Gray Level 𝑛𝑘
𝑟𝑘 PDF 𝐶𝐷𝐹 = ෍ 𝑝𝑟 𝑟𝑗 𝑠𝑘
𝑗=0

r0 = 0 790 790/4096 = 0.19 0.19 7 x 0.19 = 1.33 s0 = 1 790


r1 = 1 1023 1023/4096 = 0.25 0.44 7 x 0.44 = 3.08 s1 = 3 1023
r2 = 2 850 850/4096 = 0.21 0.65 7 x 0.65 = 4.55 s2 = 5 850
r3 = 3 656 656/4096 = 0.16 0.81 7 x 0.81 = 5.67 s3 = 6 656 +329 =
r4 = 4 329 329/4096 = 0.08 0.89 7 x 0.89 = 6.23 s4 = 6 985
r5 = 5 245 245/4096 = 0.06 0.95 7 x 0.95 = 6.65 s5 = 7 245 + 122
r6 = 6 122 122/4096 = 0.03 0.98 7 x 0.98 = 6.86 s6 = 7 + 81 = 448
r7 = 7 81 81/4096 = 0.02 1 7x1=7 s7 = 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’.
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
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

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

z0 = 0 0.00 0.00 7 x 0.00 = 0.00


z1 = 1 0.00 0.00 7 x 0.00= 0.00
z2 = 2 0.00 0.00 7 x 0.00 = 0.00
z3 = 3 0.15 0.15 7 x 0.15 = 1.05
z4 = 4 0.20 0.35 7 x 0.35 = 2.45
z5 = 5 0.30 0.65 7 x 0.65 = 4.55
z6 = 6 0.20 0.85 7 x 0.85 = 5.95
z7 = 7 0.15 1 7x1=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’.

𝑖
Gray Level 𝑝𝑧 𝑧𝑖 = 𝑛𝑖 /𝑀𝑁 𝐺(𝑧) = 𝐿 − 1 ∗ 𝐶𝐷𝐹 𝐺(𝑧)
𝑧𝑖 PDF 𝐶𝐷𝐹 = ෍ 𝑝𝑧 𝑧𝑖
𝑗=0

z0 = 0 0.00 0.00 7 x 0.00 = 0.00 0


z1 = 1 0.00 0.00 7 x 0.00= 0.00 0
z2 = 2 0.00 0.00 7 x 0.00 = 0.00 0
z3 = 3 0.15 0.15 7 x 0.15 = 1.05 1
z4 = 4 0.20 0.35 7 x 0.35 = 2.45 2
z5 = 5 0.30 0.65 7 x 0.65 = 4.55 5
z6 = 6 0.20 0.85 7 x 0.85 = 5.95 6
z7 = 7 0.15 1 7x1=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
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 = 3
r2 = 2 s2 = 5
r3 = 3 s3 = 6
r4 = 4 s4 = 6
r5 = 5 s5 = 7
r6 = 6 s6 = 7
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 = 3 0
r2 = 2 s2 = 5 0
r3 = 3 s3 = 6 1
r4 = 4 s4 = 6 2
r5 = 5 s5 = 7 5
r6 = 6 s6 = 7 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
r1 = 1 s1 = 3 0
r2 = 2 s2 = 5 0
r3 = 3 s3 = 6 1
r4 = 4 s4 = 6 2
r5 = 5 s5 = 7 5
r6 = 6 s6 = 7 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
r1 = 1 s1 = 3 0
r2 = 2 s2 = 5 0
r3 = 3 s3 = 6 1
r4 = 4 s4 = 6 2
r5 = 5 s5 = 7 5
r6 = 6 s6 = 7 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
r1 = 1 s1 = 3 0
r2 = 2 s2 = 5 0
r3 = 3 s3 = 6 1
r4 = 4 s4 = 6 2
r5 = 5 s5 = 7 5
r6 = 6 s6 = 7 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
r1 = 1 s1 = 3 0
r2 = 2 s2 = 5 0
r3 = 3 s3 = 6 1
r4 = 4 s4 = 6 2
r5 = 5 s5 = 7 5
r6 = 6 s6 = 7 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
r1 = 1 s1 = 3 0
r2 = 2 s2 = 5 0
r3 = 3 s3 = 6 1
r4 = 4 s4 = 6 2
r5 = 5 s5 = 7 5
r6 = 6 s6 = 7 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
r1 = 1 s1 = 3 0
r2 = 2 s2 = 5 0
r3 = 3 s3 = 6 1
r4 = 4 s4 = 6 2
r5 = 5 s5 = 7 5
r6 = 6 s6 = 7 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
r1 = 1 s1 = 3 0
r2 = 2 s2 = 5 0
r3 = 3 s3 = 6 1
r4 = 4 s4 = 6 2
r5 = 5 s5 = 7 5
r6 = 6 s6 = 7 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 3
r1 = 1 s1 = 3 0 4
r2 = 2 s2 = 5 0 5
r3 = 3 s3 = 6 1 6
r4 = 4 s4 = 6 2 6
r5 = 5 s5 = 7 5 7
r6 = 6 s6 = 7 6 7
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 3
r1 = 1 s1 = 3 0 4
r2 = 2 s2 = 5 0 5
r3 = 3 s3 = 6 1 6
r4 = 4 s4 = 6 2 6
r5 = 5 s5 = 7 5 7
r6 = 6 s6 = 7 6 7
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 3 790
r1 = 1 s1 = 3 0 4 1023
r2 = 2 s2 = 5 0 5 850
r3 = 3 s3 = 6 1 6 985
r4 = 4 s4 = 6 2 6
r5 = 5 s5 = 7 5 7 448
r6 = 6 s6 = 7 6 7
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
𝐺(𝑧) 𝑧𝑞 PDF
𝑟𝑘 𝑠𝑘
r0 = 0 s0 = 1 0 3 790 790/4096 = 0.19
r1 = 1 s1 = 3 0 4 1023 1023/4096 = 0.25
r2 = 2 s2 = 5 0 5 850 850/4096 = 0.21
r3 = 3 s3 = 6 1 6 985 985/4096 = 0.24
r4 = 4 s4 = 6 2 6
r5 = 5 s5 = 7 5 7 448 448/4096 = 0.11
r6 = 6 s6 = 7 6 7
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
𝐺(𝑧) 𝑧𝑞 PDF
Gray
𝑟𝑘 𝑠𝑘 Level
𝑟𝑘
r0 = 0 s0 = 1 0 3 790 790/4096 = 0.19 r0 = 0 790
r1 = 1 s1 = 3 0 4 1023 1023/4096 = 0.25 r1 = 1 1023
r2 = 2 s2 = 5 0 5 850 850/4096 = 0.21 r2 = 2 850
r3 = 3 s3 = 6 1 6 985 985/4096 = 0.24 r3 = 3 656
r4 = 4 s4 = 6 2 6 r4 = 4 329
r5 = 5 s5 = 7 5 7 448 448/4096 = 0.11 r5 = 5 245
r6 = 6 s6 = 7 6 7 r6 = 6 122
r7 = 7 s7 = 7 7 7 r7 = 7 81
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
𝐺(𝑧) 𝑧𝑞 PDF
Gray
𝑟𝑘 𝑠𝑘 Level
𝑟𝑘
r0 = 0 s0 = 1 0 3 790 790/4096 = 0.19 r0 = 0 790
r1 = 1 s1 = 3 0 4 1023 1023/4096 = 0.25 r1 = 1 1023
r2 = 2 s2 = 5 0 5 850 850/4096 = 0.21 r2 = 2 850
r3 = 3 s3 = 6 1 6 985 985/4096 = 0.24 r3 = 3 656
r4 = 4 s4 = 6 2 6 r4 = 4 329
r5 = 5 s5 = 7 5 7 448 448/4096 = 0.11 r5 = 5 245
r6 = 6 s6 = 7 6 7 r6 = 6 122
r7 = 7 s7 = 7 7 7 r7 = 7 81
Example: Histogram Matching

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

Histogram of image (c).


Histogram Matching - Example
• Perform Histogram Specification. Draw Original and matched Histogram.
• Original Image:
Gray 0 1 2 3 4 5 6 7
Level
No. of 6 4 5 7 8 10 12 12
Pixels

• 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.’

Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁


𝑟𝑘 PDF

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

r0 = 0 6 6/64 = 0.094 0.094


r1 = 1 4 0.0625 0.1565
r2 = 2 5 0.0781 0.2346
r3 = 3 7 0.109 0.343
r4 = 4 8 0.125 0.4686
r5 = 5 10 0.156 0.6246
r6 = 6 12 0.1875 0.8121
r7 = 7 12 0.1875 0.9996
Example: Histogram Matching

Step 1: To find scaled histogram equalized values ‘s’ for original image
‘r.’

𝑘
Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹
𝑟𝑘 PDF 𝐶𝐷𝐹 = ෍ 𝑝𝑟 𝑟𝑗
𝑗=0

r0 = 0 6 6/64 = 0.094 0.094 7 x 0.094=0.658


r1 = 1 4 0.0625 0.1565 1.09
r2 = 2 5 0.0781 0.2346 1.6
r3 = 3 7 0.109 0.343 2.4
r4 = 4 8 0.125 0.4686 3.2
r5 = 5 10 0.156 0.6246 4.3
r6 = 6 12 0.1875 0.8121 5.7
r7 = 7 12 0.1875 0.9996 6.9
Example: Histogram Matching

Step 1: To find scaled histogram equalized values ‘s’ for original image
‘r.’

𝑘
Gray Level 𝑛𝑘 𝑝𝑟 𝑟𝑘 = 𝑛𝑘 /𝑀𝑁 𝑠𝑘 = 𝐿 − 1 ∗ 𝐶𝐷𝐹 Gray Level
𝑟𝑘 PDF 𝐶𝐷𝐹 = ෍ 𝑝𝑟 𝑟𝑗 𝑠𝑘
𝑗=0

r0 = 0 6 6/64 = 0.094 0.094 7 x 0.094=0.658 s0 = 1


r1 = 1 4 0.0625 0.1565 1.09 s1 = 1
r2 = 2 5 0.0781 0.2346 1.6 s2 = 2
r3 = 3 7 0.109 0.343 2.4 s3 = 2
r4 = 4 8 0.125 0.4686 3.2 s4 = 3
r5 = 5 10 0.156 0.6246 4.3 s5 = 4
r6 = 6 12 0.1875 0.8121 5.7 s6 = 6
r7 = 7 12 0.1875 0.9996 6.9 s7 = 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’.

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’.

Gray Level 𝑛𝑘 𝑝𝑧 𝑧𝑖 = 𝑛𝑖 /𝑀𝑁


𝑧𝑖 PDF

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

z0 = 0 0 0.00 0.00 7 x 0.00 = 0.00


z1 = 1 0 0.00 0.00 7 x 0.00= 0.00
z2 = 2 0 0.00 0.00 7 x 0.00 = 0.00
z3 = 3 0 0.00 0.00 7 x 0.00 = 0.00
z4 = 4 10 0.156 0.156 7 x 0.156 = 1.092
z5 = 5 20 0.3125 0.4685 7 x 0.4685 = 3.27
z6 = 6 22 0.3438 0.8123 7 x 0.8123 = 5.68
z7 = 7 12 0.1875 0.9998 7 x 0.9998 = 6.998

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

z0 = 0 0 0.00 0.00 7 x 0.00 = 0.00 0


z1 = 1 0 0.00 0.00 7 x 0.00= 0.00 0
z2 = 2 0 0.00 0.00 7 x 0.00 = 0.00 0
z3 = 3 0 0.00 0.00 7 x 0.00 = 0.00 0
z4 = 4 10 0.156 0.156 7 x 0.156 = 1.092 1
z5 = 5 20 0.3125 0.4685 7 x 0.4685 = 3.27 3
z6 = 6 22 0.3438 0.8123 7 x 0.8123 = 5.68 6
z7 = 7 12 0.1875 0.9998 7 x 0.9998 = 6.998 7

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.

• At each location, the histogram of the points in the neighborhood is computed.


Either histogram equalization or histogram specification transformation function is
obtained.

• Map the intensity of the pixel centered in the neighborhood.

• Move to the next location and repeat the procedure


Local Histogram Processing: Example
Local Histogram Processing: Example
Local Histogram Processing: Example
Figure 3.33
(a) Original image. (b) Result of local enhancement based on
local histogram statistics. Compare (b) with Fig. 3.32(c).
Using Histogram Statistics for Image Enhancement
Using Histogram Statistics for Image Enhancement

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 𝑆𝑥𝑦

Local average intensity


L 1
msxy   ri psxy (ri )
i 0

sxy denotes a neighborhood


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 𝑆𝑥𝑦

Local average intensity Local variance


L 1 L 1

msxy   ri psxy (ri )  s2   (ri  ms ) 2 ps (ri )


xy xy xy
i 0
i 0

sxy denotes a neighborhood


Image Enhancement using Local histogram statistics
• Measure whether an area is relatively light or dark at (x,y). Compare
the local average gray level 𝑚𝑆𝑥𝑦 to the global mean 𝑚𝐺 .
• (x,y) is a candidate for enhancement if 𝑚𝑆𝑥𝑦 ≤ 𝑘0 𝑚𝐺
• Enhance areas that have low contrast
• Compare the local standard deviation 𝜎𝑆𝑥𝑦 to the global standard
deviation 𝜎𝐺
• (x,y) is a candidate for enhancement if 𝜎𝑆𝑥𝑦 ≤ 𝑘2 𝜎𝐺
• Restrict lowest values of contrast
• (x,y) is a candidate for enhancement if 𝑘1 𝜎𝐺 ≤ 𝜎𝑆𝑥𝑦

You might also like