0% found this document useful (0 votes)
6 views51 pages

Chapter 3 Part 1

Chapter 3 of the document discusses spatial domain image processing techniques, which manipulate image pixels for enhancement. It covers various intensity transformation functions, including linear, logarithmic, power-law, and piecewise-linear transformations, as well as histogram processing methods like histogram equalization. The chapter emphasizes the importance of these techniques in improving image quality and contrast for better visual representation.

Uploaded by

ajebaderesa12
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)
6 views51 pages

Chapter 3 Part 1

Chapter 3 of the document discusses spatial domain image processing techniques, which manipulate image pixels for enhancement. It covers various intensity transformation functions, including linear, logarithmic, power-law, and piecewise-linear transformations, as well as histogram processing methods like histogram equalization. The chapter emphasizes the importance of these techniques in improving image quality and contrast for better visual representation.

Uploaded by

ajebaderesa12
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/ 51

Computer Vision and Image Processing

Chapter 3

Spatial Domain Image


Processing
Contents

01 Spatial Processing of Digital Images

02 Basic Intensity Transformation Functions

03 Spatial filtering

04 Histogram of images and Histogram processing

05 Combining Spatial Enhancement Methods


Image Enhancement:
Introduction
• The process of highlighting certain information of an image, as well as
weakening or removing any unnecessary information according to specific
needs.
Image enhancement techniques can be divided into two broad categories:
• Spatial domain: refers to the image plane itself.
⚬ Spatial domain processing techniques directly manipulate the image pixels
to achieve desired results.
• Frequency domain: refers to the Fourier transform of the image rather than the
spatial pixel values.
⚬ Obtained by applying the Fourier Transform to the spatial domain.
⚬ The Fourier transform reveals the frequency components present in the
image.
Types of Spatial Domain Technique

• Point operation (intensity transformation): refer to running the same


conversion operation for each pixel in a grayscale image.
⚬ The transformation is based on the original pixel and is independent of its
location or neighboring pixels.
• Spatial filter (or mask, kernel): the output value depends on the values of
f(x,y) and its neighborhood.
3.1 Spatial Processing of Digital Images

Spatial domain processes will be denoted by the expression:


g(x,y) = T[f(x,y)] where:
• f(x, y) is the input image,
• g(x, y) is the processed image, and
• T is an operator on f
3.2 Basic Intensity Transformation Functions
Intensity Transformations are applied on images for contrast manipulation or
image thresholding.
The following are commonly used intensity transformations:
➢ Linear Transformations
➢ Log Transformations
➢ Power-Law (Gamma) Transformations
➢ Piecewise-Linear Transformation Functions
Linear Transformation

Linear transformation includes simple identity and negative transformation.

Identity Tansformation: each value of the input image is directly mapped to each
other value of output image.
• Identity transformation/transition is shown by a straight line.

output
⚬ That results is the same in input
image and output image.
⚬ And hence is called identity
transformation.
Input
Negative Transformation

Negative Transformation is invert of identity transformation.


In negative transformation, each value of the input image is subtracted from the
L-1 and mapped onto the output image
• Also known as Image Negative.
The image negative with gray level value in
the range of [0, L-1] is obtained by negative
transformation given by S = T(r);
S = (L -1) – r

Where r= gray level value at pixel (x,y)


L-1 is the largest gray level consists in the image
Negative Transformation cont...

Since the input image of Mine is an 8 bpp


image, so the number of levels in this image
are 256.
Putting 256 in the equation, we get this
s = 255 – r

So each value is subtracted by 255 and the result image has been shown
above.
So what happens is that, the lighter pixels become dark and the darker
picture becomes light.
It is useful when for enhancing white details embedded in dark regions of the
image.
Negative Transformation cont...

a) input pixel value = 0 , then output pixel value will be 255.


b) input pixel value = 100 , then output pixel value will be 155.
c) input pixel value = 255, then output pixel value will be 0.
d) input pixel value = x, then output pixel value will be 255-x.
Logarithmic Transformations
Logarithmic transformation further contains two type of transformation.
• Log transformation and
• Inverse log transformation.

Log transformation defined by:


s = c log(r + 1) Where :
• s and r are the pixel values of the output and the input image
• c is a constant
Why we add 1 on intensity value(r) ?
• To make the minimum value at least 1
• B/c log (0) is equal to infinity
Logarithmic Transformations
During log transformation, the dark
pixels in an image are expanded as
compared to the higher pixel values.

The higher pixel values are kind of


compressed in log transformation.

Meaning, darker pixel


get brighter whereas the
brighter pixels don’t input band
change much. output band
after Log Transformation
Logarithmic Transformations
If we apply this method in an image having higher pixel values then it will
enhance the image more and actual information of the image will be lost.
So, this method can’t be applied everywhere.
It can be applied in images where low pixel values are more than higher ones.
Inverse Log Transformation
The inverse log transformation, also known as exponential transformation, is
the inverse operation of the log transformation.
It is used to expand the dynamic range of pixel intensities or to undo the
compression performed by the log transformation.
The inverse log transformation is defined as:
s = (exp(r) .^ (1/c)) – 1 where:

• 'r' represents the input pixel value,


• 's' represents the transformed output pixel value,
• 'exp' denotes the exponential function, and
• 'c' is the same scaling factor used in the log transformation.
Inverse Log Transformation
The inverse log transformation, also known as exponential transformation, is
the inverse operation of the log transformation.
It is used to expand the dynamic range of pixel intensities or to undo the
compression performed by the log transformation.
The inverse log transformation is defined as:
s = exp(r/c) - 1 where:
• 'r' represents the input pixel value,
• 's' represents the transformed output pixel value,
• 'exp' denotes the exponential function, and
• 'c' is the same scaling factor used in the log transformation.
⚬ To map from [0,255] to [0,255], c =LOG(256)/255
Inverse Log Transformation

The inverse log transformation restores the


original intensity values of an image that has
undergone the log transformation.
Power Law (Gamma) Transformations
There are further two transformation is power law transformations (also known
as Gamma Correction)
This transformations are nth power and nth root transformation.

It is a common technique used in image processing to adjust the overall


brightness and contrast of an image.

These transformations can be given by the expression:


s=cr^γ
Where:
'r' represents the input pixel value.
's' represents the transformed output pixel value.
'c' is a constant scaling factor.
'γ' is the gamma parameter that controls the correction strength.
Power Law (Gamma) Transformations

The gamma parameter, γ, typically ranges between 0 and 1. If γ < 1, the


transformation darkens the image and enhances the contrast in the brighter regions.

This is useful when correcting overexposed images or when emphasizing details in


the highlights.

Conversely, if γ > 1, the transformation brightens the image and enhances the
contrast in the darker regions.

This is useful for correcting underexposed images or enhancing details in the


shadows.
Power Law (Gamma) Transformations
The gamma correction is often applied to compensate for the non-linear
response of display devices or imaging systems.

It ensures that the perceived brightness of an image matches the intended


visual appearance.

Variation in the value of γ varies the enhancement of the images.

Different display devices / monitors have their own gamma correction, that’s why
they display their image at different intensity.
Power Law (Gamma) Transformations
• Variation in the value of γ varies the
enhancement of the images.

• Different display devices / monitors


have their own gamma correction,
that’s why they display their image at
different intensity.

Plot of the equation s=cr^γ for various values of γ (c =1 in all cases).


Piecewise-Linear Transformation
In mathematics, a piecewise-defined function is a function defined by multiple
sub-functions, where each sub-function applies to a different interval in the
domain.

Rather than using a well defined mathematical function we can use arbitrary
user-defined transforms

Principle Advantage: Some important transformations can be formulated only


as a piecewise function.

Principle Disadvantage: Their specification requires more user input that


previous transformations
Piecewise-Linear Transformation
Types of Piecewise transformations are:
• Contrast Stretching, Threshold
• Gray-level Slicing
• Bit-plane slicing
Contrast Stretching: Contrast stretching, also known as normalization, is a
technique used to expand the range of pixel intensities in an image to span the
full dynamic range.
Gray Level Slicing: Gray level slicing aims to selectively enhance or emphasize
specific intensity ranges in an image.
Bitplane slicing: is a technique used in digital image processing to extract and
analyze the individual bits of image pixel values.
• Contrast Stretching Piecewise-Linear Transformation
Contrast Stretching: one of the simplest piecewise linear functions is a
contrast-stretching transformation, which is used to enhance the low contrast
images.
Low contrast images may result from:
• Poor illumination
• Wrong setting of lens aperture during image acquisition.
• Contrast Stretching Piecewise-Linear Transformation
If T(r) has the form as shown in the figure below, the effect of applying the
transformation to every pixel of f to generate the corresponding pixels in g
would:
Produce higher contrast than the original image, by:
• Darkening the levels below m in the original image
• Brightening the levels above m in the original image

So, Contrast Stretching: is a simple image


enhancement technique that improves the contrast in
an image by ‘stretching’ the range of intensity values it
contains to span a desired range of values.
Piecewise-Linear Transformation
Contrast stretching and thresholding
Assume that
a: rmin,
b:rmax,

Contrast stretching: (r1,s1)=(rmin,0) , (r2,s2)=(rmax,L-1)


Piecewise-Linear Transformation
Contrast stretching
Example: in the graph, suppose we have the following
intensities : a=90, b=180, m=100
• if r is above 180 ,it becomes 255 in s.
• If r is below 90 , it becomes 0,
• If r is between 90, 180 , T applies as follows:
• when r < 100 , s closes to zero (darker)
• when r>100 , s closes to 255 (brighter)

This is called contrast stretching, which means that the bright pixels in the
image will become brighter and the dark pixels will become darker, this means :
higher contrast image.
Piecewise-Linear Transformation
Contrast stretching

Notice that the intensity transformation function T, made the pixels with dark
intensities darker and the bright ones even more brighter, this is called contrast
stretching
Piecewise-Linear Transformation
Contrast stretching

Notice that the intensity transformation function T, made the pixels with dark
intensities darker and the bright ones even more brighter, this is called contrast
stretching
Piecewise-Linear Transformation
Thresholding
Is a limited case of contrast stretching, it produces a two-level (binary) image.

Some fairly simple, yet powerful, processing


approaches can be formulated with grey-level
transformations.

Because enhancement at any point in an image


depends only on the gray level at that point,
techniques in this category often are referred to
as point processing.
Piecewise-Linear Transformation
Thresholding
Is a limited case of contrast stretching, it produces a two-level (binary) image.

Assume that
• a: rmin,
• b:rmax,
• k : intensity

Contrast stretching:
• (r1,s1)=(rmin,0) , (r2,s2)=(rmax,L-1)
Thresholding:
• (r1,s1)=(k,0) , (r2,s2)=(k,L-1)
Thresholding
Piecewise-Linear Transformation
Thresholding
g(x,y) = T[f(x,y)] Or s= Example: suppose m= 150 (called threshold),
T(r) if r (or pixel intensity in image f) is above this threshold
it becomes 1 in s (or pixel intensity in image g),
otherwise it becomes zero.

This is called thresholding, and it produces a binary


image!
Piecewise-Linear Transformation
Thresholding
Example:
8-bit image with low contrast

After contrast stretching


(r1,s1)=(rmin,0) ,
(r2,s2)=(rmax,L-1)
Notice that the intensity transformation function T, convert
the pixels with dark intensities into black and the bright Thresholding function
pixels into white.
(r1,s1)=(m,0) , (r2,s2)=(m,L-1)
Pixels above threshold is considered bright and below it is
m : mean intensity level in the
considered dark, and this process is called thresholding.
image.
Piecewise-Linear Transformation
Gray-level Slicing
This technique is used to highlight a specific range of gray levels in a
given image.
• Similar to thresholding
• Other levels can be suppressed or maintained
• Useful for highlighting features in an image
It can be implemented in several ways, but the two basic themes are:

• One approach is to display a high value for all gray levels in the range of
interest and a low value for all other gray levels.
• The second approach, based on the transformation brightens the desired
range of gray levels but preserves gray levels unchanged.
Piecewise-Linear Transformation
Gray-level Slicing
Approach 1 Approach 2

Display in one value(e.g white) all the Brightens or darkens the desired
values in the range of interest , and in range of intensities but leaves all
another (e.g black) all other other intensity levels in the image
intensities unchanged
Piecewise-Linear Transformation
Bitplane Slicing
Pixels are digital numbers, each one composed of bits. Instead of highlighting
gray-level range, we could highlight the contribution made by each bit.

This method is useful and used in image compression.

Most significant bits contain the majority of visually significant data.


Piecewise-Linear Transformation
Bitplane Slicing
Often by isolating particular bits of the pixel values in an image we can
highlight interesting aspects of that image
• Higher-order bits usually contain most of the significant visual information.
Lower-order bits contain subtle details
Bitplane Slicing Piecewise-Linear Transformation
2
of
39
Histogram

• In image processing, a histogram shows the number of pixels for each intensity
value in a given image.
• A histogram is a statistical representation of an image.
• It doesn’t show any information about where the pixels are located in the image.
• Therefore, two different images can have equivalent histograms.
3
of
39
Image Histogram
4
of
39
Histogram Equalization
• Histogram equalization (also known as
histogram flattening).
• The goal is to improve contrast in images that
might be either blurry or have a background and
foreground that are either both bright or both dark.
• Histogram equalization helps sharpen an image.
5
of
39
Histogram Equalization
6
of How Histogram Equalization Works
39

• Step 1: Obtain the histogram.

• Step 2: Obtain the cumulative distribution function CDF.

– Note: The sum of all the components in the normalized histogram is equal to 1.
• Step 3: Calculate the transformation T to map the old intensity values to new
intensity values.
– Let K represent the total number of possible intensity values (e.g. 256).

• Step 4: Given the new mappings of intensity values, we can use a lookup table to transform
each pixel in the input image to a new intensity.
7
of Example of Histogram Equalization
39

• Let us suppose we have a 3-bit, 8 x 8 grayscale image.


• The grayscale range is 23 = 8 intensity values (i.e. gray levels) because the image is 3 bits.
• We label these intensity values 0 through 7.
• Below is the histogram of this image.

• Now, calculate the cumulative distribution function and perform the


transformation.
8
of
39
Solution

The two yellow columns above are our lookup table and we
use these two columns to generate the output image.
9
of
39
Solution cont..
10
of
39
Histogram Matching

• The goal of histogram equalization is to produce an output image that has a


flattened histogram.
• The goal of histogram matching is to take an input image and generate an
output image that is based upon the shape of a specific (or reference) histogram
• Histogram matching is also known as histogram specification.
• Let us suppose we have two images, an input image and a specified image.
• We want to use histogram matching to force the input image to have a
histogram that is the shape of the histogram of the specified image.
• The first few steps are similar to histogram equalization, except we are
performing histogram equalization on two images (original image and the
specific image).
11
of
39
Steps for histogram matching
• Step 1: Obtain the histogram for both the input image and the specified image (same method
as in histogram equalization).

• Step 2: Obtain the cumulative distribution function CDF for both the input image and the
specified image (same method as in histogram equalization).

• Step 3: Calculate the transformation T to map the old intensity values to new intensity
values for both the
input image and specified image (same method as in histogram equalization).

• Step 4: Use the transformed intensity values for both the input image and
specified image to map the intensity values of the input image to new values
12
of Example of Histogram Matching
39

• From the previous histogram equalization we have


equalized original input image and the following
specified histogram.

• Doing similar process of histogram equalization for


specified image as input image yields the following:
13
of
39
Solution

• Using the two yellow columns above to map the old intensity values for the pixels to new intensity
values, we get the following histogram after equalization:
14
of
39
Solution cont..
• Now, transform intensity values for both the input image and specified image to map the intensity
values of the input image to new values.
• To do that, all we need are the FLOOR((K – 1) * CDF) values for both the original and the specified
image.

For example, when the gray level is 4, the original image is 2. 2 in the specified image corresponds
to a gray
level of 1. Therefore, we map 4 to 1.
Part I End

Question?

You might also like