0% found this document useful (0 votes)
20 views38 pages

Chapter 3 Part 1

Chapter 3 of the document discusses spatial domain image processing techniques, focusing on image enhancement methods that manipulate pixel values directly. Key topics include intensity transformation functions, spatial filtering, and histogram processing, with specific techniques like linear, logarithmic, and power-law transformations explained in detail. The chapter also covers piecewise-linear transformations such as contrast stretching, thresholding, gray-level slicing, and bitplane slicing, highlighting their applications in enhancing image quality.

Uploaded by

mimitsegent
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)
20 views38 pages

Chapter 3 Part 1

Chapter 3 of the document discusses spatial domain image processing techniques, focusing on image enhancement methods that manipulate pixel values directly. Key topics include intensity transformation functions, spatial filtering, and histogram processing, with specific techniques like linear, logarithmic, and power-law transformations explained in detail. The chapter also covers piecewise-linear transformations such as contrast stretching, thresholding, gray-level slicing, and bitplane slicing, highlighting their applications in enhancing image quality.

Uploaded by

mimitsegent
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/ 38

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

1. 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.
2. 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.

That results is the same in

output
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 undefined value.
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 input band
brighter pixels don’t output band
change much. 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 brightens the image and enhances the contrast in the
darker regions.

This is useful for correcting underexposed images or for emphasizing


details in the shadows, not overexposed images.

Conversely, if γ > 1, the transformation darkens the image and


enhances the contrast in the brighter regions (highlights), not the
darker regions.
This is useful for correcting overexposed images or enhancing details
in the highlights, not 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:
a. when r < 100 , s closes to zero (darker)
b. 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 Example: suppose m= 150 (called threshold),
s= 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 Thresholding function
intensities into black and the bright pixels into
(r1,s1)=(m,0) , (r2,s2)=(m,L-1)
white.
Pixels above threshold is considered bright and m : mean intensity level in the
below it is considered dark, and this process is image.
called thresholding.
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) Brightens or darkens the


all the values in the range of desired range of intensities but
interest , and in another (e.g leaves all other intensity levels
black) all other intensities in the image 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
Part I End

Question?

You might also like