You are on page 1of 52

Intensity Transformations Instructor

Engr Dr Muhammad
and Spatial Filtering Jamil Khan
Objectives
❑ Spatial domain processing Vs transform domain processing.

❑ Techniques used for intensity transformations.

❑ Histogram

❑ Histogram Equalization

❑ Histogram Matching
Spatial Domain
The term spatial domain refers to the image plane itself, and
image processing methods in this category are based on
direct manipulation of pixels in an image.
Spatial Domain
Two principal categories of spatial processing are

1. Intensity transformations

2. Spatial filtering
Spatial Domain
Intensity transformations operate on single pixels of an
image for tasks such as contrast manipulation and image
thresholding.
Spatial Domain
Spatial filtering performs operations on the neighborhood of
every pixel in an image.

Examples of spatial filtering include image smoothing and


sharpening.
Spatial Domain
Representing digital image

value f(x,y) at each x, y is called intensity level or gray level


Image as a Matrix
Image as a Matrix

Coordinate convention
used to represent digital
images. Because
coordinate values are
integers, there is a one-to-
one Correspondence
between x and y and the
rows (r) and columns (c)
of a matrix.
Spatial Domain

g ( x, y ) = T [ f ( x, y )])
f ( x, y ) : input image
g ( x, y ) : output image
T : an operator on f defined over
a neighborhood of point ( x, y )
Spatial Domain

A 3 × 3 neighborhood
about a point (x , y ) 0 0
in an image.
The neighborhood is
moved from pixel to
pixel in the image to
generate an output
image.
Spatial Domain
 1 𝑥 1 is the smallest possible neighborhood.

 In this case g depends only on value of f at a single 𝑝𝑜𝑖𝑛𝑡 (𝑥, 𝑦) and we call 𝑇 an

intensity (gray-level mapping) transformation and write

𝑠 = 𝑇(𝑟)

where 𝑟 and 𝑠 denotes respectively the intensity of 𝑔 and 𝑓 at any

𝑝𝑜𝑖𝑛𝑡 (𝑥, 𝑦).


Spatial Domain
The result of applying the transformation to every pixel in 𝒇
to generate the corresponding pixels in 𝒈 would be to
produce an image of higher contrast than the original, by
darkening the intensity levels below 𝒌 and brightening the
levels above 𝒌. In this technique, sometimes called contrast
stretching.
Spatial Domain
Intensity transformation function
s = T (r )
Transform Domain

▪ Transforming the images


▪ Carrying the specified task
in a transform domain
▪ Applying the inverse
transform
Transform Domain
a b
c d

a. Image corrupted by sinusoidal


interference.
b. Magnitude of the Fourier
transform showing the bursts of
energy caused by the Interference
(the bursts were enlarged for
display purposes).
c. Mask used to eliminate the
energy bursts.
d. Result of computing the inverse of
the modified Fourier transform.
(Original image courtesy of NASA.)
Transform Domain
a b
c d

a. Image corrupted by sinusoidal


interference.
b. Magnitude of the Fourier
transform showing the bursts of
energy caused by the Interference
(the bursts were enlarged for
display purposes).
c. Mask used to eliminate the
energy bursts.
d. Result of computing the inverse of
the modified Fourier transform.
(Original image courtesy of NASA.)
Some Basic Intensity Transformation Functions
Some basic intensity
Transformation functions.
Each curve was scaled
independently so that all
curves would fit in the same
graph. Our interest here is
on the shapes of the curves,
not on their relative values.
Image Negative
Denote [0, 𝐿 − 1] intensity levels of the image.

Image negative is obtained by


𝑠 = 𝐿−1−𝑟
Image Negative
Image Negative
Image Negative
Denote [0, 𝐿 − 1] intensity levels of the image.

Image negative is obtained by


𝑠 = 𝐿−1−𝑟
Log Transformation
The general form of the log
transformation
𝒔 = 𝒄𝒍𝒐𝒈(𝟏 + 𝒓)
where 𝑐 is a constant and it is
assumed that 𝑟 ≥ 0.
Maps a narrow range of low intensity
values in the input into a wider range
of output levels. The opposite is true
for higher values of input levels.
Log Transformation

(a) Fourier spectrum displayed as a grayscale image.


(b) Result of applying the log Transformation with c = 1. Both images are
scaled to the range [0, 255].
POWER-LAW (GAMMA) TRANSFORMATIONS
Power-law transformations have the form

𝛾
𝑠 = 𝑐𝑟

where 𝑐 and 𝛾 are positive constants.


POWER-LAW (GAMMA) TRANSFORMATIONS
POWER-LAW (GAMMA) TRANSFORMATIONS
GAMMA TRANSFORMATIONS
a b
c d

(a) Magnetic resonance image


(MRI) of a fractured human
spine (the region of the
fracture is enclosed by the
circle).
(b)–(d) Results of applying the
Transformation in gamma
transformation equation with
𝒄 = 𝟏 and γ = 0 6 . , 0.4, and
𝟎. 𝟑, respectively.
GAMMA TRANSFORMATIONS
a b
c d

(a) Aerial image.


(b)–(d) Results of applying the
Transformation in Eq. with
𝛾 = 3 0 . , 4.0, 𝑎𝑛𝑑 5.0 ,
respectively. (c = 1 in all
cases.)
Piece-wise Linear Transformation Functions
An approach complementary to the methods discussed in the previous
sections is to use piecewise linear functions.
The advantage of these functions over those discussed thus far is that the
form of piecewise functions can be arbitrarily complex. In fact, as you will see
shortly, a practical implementation of some important transformations can be
formulated only as piecewise linear functions.
The main disadvantage of these functions is that their specification requires
considerable user input.
Contrast Stretching
Low-contrast images can result from

− poor illumination,

− lack of dynamic range in the imaging sensor,

− the wrong setting of a lens aperture during image acquisition.

Contrast stretching expands the range of intensity levels in an image so that it

spans the ideal full intensity range of the recording medium or display device.
Contrast Stretching
Intensity-Level Slicing
There are applications in which it is of interest to highlight a specific range of
intensities in an image. Some of these applications include enhancing features
in satellite imagery, such as masses of water, and enhancing flaws in X-ray
images.
The method, called intensity-level slicing, can be implemented in several
ways, but most are variations of two basic themes. One approach is to display
in one value (say, white) all the values in the range of interest and in another
(say, black) all other intensities.
Intensity-Level Slicing
Intensity-Level Slicing
Bit-Plane Slicing
Pixel values are integers composed of bits. For example, values in a 256-level
grayscale image are composed of 8 bits (one byte). Instead of highlighting
intensity-level ranges, we could highlight the contribution made to total
image appearance by specific bits.
Bit-Plane Slicing
Bit-Plane Slicing
Bit-Plane Slicing
Histogram Processing
 Histogram Equalization

 Histogram Matching

 Local Histogram Processing

 Using Histogram Statistics for Image Enhancement


Histogram Processing
The histogram of a digital image with gray levels in the range
[0, 𝐿 − 1] is a discrete function
ℎ(𝑟𝑘) = 𝑛𝑘
where 𝑟𝑘 is the 𝑘𝑡ℎ gray level and 𝑛𝑘 is the number of pixels
in the image having gray level 𝑟𝑘. and the subdivisions of the
intensity scale are called histogram bins.
Histogram Processing
It is common practice to normalize a histogram by dividing
each of its values by the total number of pixels in the image,
denoted by the product 𝑀𝑁. Thus, a normalized histogram
is given by
𝑛𝑘
ℎ(𝑟𝑘) =
𝑀𝑁
The sum of all components of a normalized histogram is
equal to 1.
Histogram Processing
Histogram Equalization
It is common practice to normalize a histogram by dividing
each of its values by the total number of pixels in the image,
denoted by the product 𝑀𝑁. Thus, a normalized histogram
is given by
𝑛𝑘
ℎ(𝑟𝑘) =
𝑀𝑁
The sum of all components of a normalized histogram is
equal to 1.
Histogram Equalization
The intensity levels in an image may be viewed as
random variables in the interval [0, L-1].
Let pr (r ) and ps ( s) denote the probability density
function (PDF) of random variables r and s.
Histogram Equalization
How to implement histogram equalization?
Step 1:For images with discrete gray values, compute:
L: Total number of gray levels

nk: Number of pixels with gray value rk

n: Total number of pixels in the image

Step 2: Based on CDF, compute the discrete version of the


previous transformation :
Histogram Equalization Example
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has
the intensity distribution shown in following table.
Get the histogram equalization transformation function and give the
ps(sk) for each sk.
Histogram Equalization Example
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has
the intensity distribution shown in following table.
Get the histogram equalization transformation function and give the
ps(sk) for each sk.
Histogram Equalization Example
0
s0 = T (r0 ) = 7 pr (rj ) = 7  0.19 = 1.33 → 1
j =0

1
s1 = T (r1 ) = 7 pr (rj ) = 7  (0.19 + 0.25) = 3.08 → 3
j =0

s2 = 4.55 → 5 s3 = 5.67 → 6
s4 = 6.23 → 6 s5 = 6.65 → 7
s6 = 6.86 → 7 s7 = 7.00 → 7
Histogram Equalization Example
Histogram Equalization Example

You might also like