Digital Image Processing
Lecture 3: Image Enhancement in Spatial
Domain
MARYIAM ZAHOOR
Image Enhancement
2
Process an image to make the result more suitable than the
original image for a specific application
–Image enhancement is subjective (problem /application oriented)
Image enhancement methods:
Spatial domain: Direct manipulation of pixel in an image (on
the image plane)
Frequency domain: Processing the image based on modifying the
Fourier transform of an image
Many techniques are based on various combinations of methods from
these two categories
04/06/21
3
Image Enhancement
04/06/21
4
Basic Concepts
Spatial domain enhancement methods can be generalized as
g(x,y)=T[f(x,y)]
f(x,y): input image
g(x,y): processed (output) image
T[*]: an operator on f (or a set of input images),
defined over neighborhood of (x,y)
Neighborhood about (x,y): a square or rectangular
sub-image area centered at (x,y)
04/06/21
5
Basic Concepts
04/06/21
6
Basic Concepts
g(x,y) = T [f(x,y)]
Pixel/point operation:
Neighborhood of size 1x1: g depends only on f at (x,y)
T: a gray-level/intensity transformation/mapping function
Let r = f(x,y) s = g(x,y)
r and s represent gray levels of f and g at (x,y)
Then s = T(r)
Local operations:
g depends on the predefined number of neighbors of f at (x,y)
Implemented by using mask processing or filtering
Masks (filters, windows, kernels, templates) :
a small (e.g. 3×3) 2-D array, in which the values of the
coefficients determine the nature of the process
04/06/21
7
Common Pixel Operations
Image Negatives
Log Transformations
Power-Law
Transformations
04/06/21
8
Image Negatives
Reverses the gray level order
For L gray levels the transformation function is
s =T(r) = (L - 1) - r
04/06/21
9
Image Scaling
s =T(r) = a.r (a is a constant)
04/06/21
Log Transformations 10
Function of s = cLog(1+r)
04/06/21
Log Transformations
11
Properties of log transformations
–For lower amplitudes of input image the range of gray levels
is expanded
–For higher amplitudes of input image the range of gray levels
is compressed
Application:
This transformation is suitable for the case when the dynamic
range of a processed image far exceeds the capability of the
display device (e.g. display of the Fourier spectrum of an
image)
Also called “dynamic-range compression / expansion”
04/06/21
Log Transformations
12
04/06/21
13
Power-Law Transformation
04/06/21
14
Power-Law Transformation
For γ < 1: Expands values of dark pixels,
compress values of brighter pixels
For γ > 1: Compresses values of dark pixels,
expand values of brighter pixels
If γ=1 & c=1: Identity transformation (s = r)
A variety of devices (image capture, printing, display) respond according to
power law and need to be corrected
Gamma (γ) correction
The process used to correct the power-law response phenomena
04/06/21
15
Gamma Correction
04/06/21
16
Power Law Example
04/06/21
17
Power Law Example (cont…)
γ = 0.6
1
0.9
0.8
Transformed Intensities
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Old Intensities
04/06/21
18
Power Law Example (cont…)
γ = 0.4
1
0.9
Transformed Intensities
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
04/06/21
19
Power Law Example (cont…)
γ = 0.3
1
0.9
Transformed Intensities
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
04/06/21
Power Law Example (cont…) 20
s = r 0.6
The images to the
right show a
magnetic resonance
(MR) image of a s=
fractured human r
s = r 0.4
0 .3
spine
Different curves
highlight different
detail
04/06/21
Power Law Example 21
04/06/21
Power Law Example (cont…) 22
γ = 5.0
1
0.9
Transformed Intensities
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1
Original Intensities
04/06/21
23
Power Law Transformations (cont…)
An aerial photo
of a runway is s = r 3.0
shown
This time
power law
transforms are
s = r 4.0
s=
used to darken r 5 .0
the image
Different curves
highlight
different detail
04/06/21
Piecewise-Linear 24
Transformation
Contrast Stretching
Goal:
Increase the dynamic range of the gray levels for low contrast
images
Low-contrast images can result from
–poor illumination
–lack of dynamic range in the imaging sensor
–wrong setting of a lens aperture during image acquisition
04/06/21
25
Contrast Stretching Example
04/06/21
Piecewise-Linear Transformation: 26
Contrast Stretching
04/06/21
27
Thresholding
04/06/21
28
Gray Level Slicing
Highlighting a specific range of Gray
levels in an image
First approach
Display a high value for all the gray
levels in the range of interest
Low value for all other gray levels
This will produce a Binary Image
04/06/21
29
Gray Level Slicing
2nd approach
Brightensthe desired range of
Gray Levels but preserves the
Gray Levels of rest of the pixels
04/06/21
30
Bit Plane Slicing
Given an X-bit per pixel image,
slicing the image at different
planes (bit-planes)
An application of this
technique is data compression
In general, 8-bit per pixel
images are processed.
Zero is the least significant bit
(LSB) and 7 is the most
significant bit (MSB):
04/06/21
31
Bit Plane 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
04/06/21
32
Example
04/06/21