Digital Image Processing
Chapter 3:
Image Enhancement in the
Spatial Domain
Principle Objective of
Enhancement
Process an image so that the result will be more
suitable than the original image for a specific
application.
Techniques are problem oriented.
A method which is quite useful for enhancing an
image may not necessarily be the best approach
for enhancing another images
No general theory on image enhancement exists.
2 domains
Spatial Domain (image plane):
Techniques are based on direct manipulation of
pixels in an image.
Gray level transformations.
Histogram processing.
Arithmetic/Logic operations.
Filtration techniques.
Frequency Domain :
Techniques are based on modifying the Fourier
transform of an image
Good images
For human visual
The visual evaluation of image quality is a highly
subjective process.
It is hard to standardize the definition of a good
image.
For machine perception
The evaluation task is easier.
A good image is one which gives the best machine
recognition results.
A certain amount of trial and error usually is
required before a particular image
enhancement approach is selected.
Spatial Domain
Procedures that operate
directly on pixels.
g(x,y) = T[f(x,y)]
where
f(x,y) is the input image
g(x,y) is the processed
image
T is an operator on f
defined over some
neighborhood of (x,y)
Mask/Filter
Neighborhood of a point (x,y)
can be defined by using a
square/rectangular (common
(x,y)
used) or circular subimage
area centered at (x,y)
• The center of the subimage
is moved from pixel to pixel
starting at the top of the
corner
Point Processing
Neighborhood = 1x1 pixel
g depends on only the value of f at (x,y)
T = gray level (or intensity or mapping)
transformation function
s = T(r)
Where
r = gray level of f(x,y)
s = gray level of g(x,y)
Contrast Stretching
Produce higher
contrast than the
original by
darkening the levels
below m in the original
image
Brightening the levels
above m in the original
image
Thresholding
Produce a two-level
(binary) image
Mask Processing or Filter
Neighborhood is bigger than 1x1 pixel
The value of the mask coefficients determine
the nature of the process
Used in techniques
Image Sharpening
Image Smoothing
3 basic gray-level
transformation functions
Linear function
Negative
nth root
Negative and identity
Output gray level, s
transformations
Log
nth power Logarithm function
Log and inverse-log
transformation
Power-law function
Identity Inverse Log
nth power and nth root
transformations
Input gray level, r
Identity function
Output intensities
Negative
are identical to input
nth root
intensities.
Output gray level, s
Log
nth power
Is included in the
graph only for
completeness.
Identity Inverse Log
Input gray level, r
Image Negatives
An image with gray level in
Negative the range [0, L-1]
nth root where L = 2n ; n = 1, 2…
Output gray level, s
Log
Negative transformation :
nth power
s = L – 1 –r
Reversing the intensity
levels of an image.
Suitable for enhancing white
Identity Inverse Log
or gray detail in dark
background.
Input gray level, r
Example of Negative Image
Original Image showing Negative Image : gives a
a small lesion better vision to analyze
the image
Log Transformations
s = c log (1+r)
Negative
c is a constant
nth root and r ≥ 0
Output gray level, s
Log
Log curve maps a narrow
nth power range of low gray-level
values in the input image
into a wider range of
output levels.
Inverse Log
Expand dark value to
Identity
enhance details of dark
area.
Input gray level, r
Log Transformations
It compresses the dynamic range of images
with large variations in pixel values
Example of image with dynamic range: Fourier
spectrum image
It can have intensity range from 0 to 106 or
higher.
We can’t see the significant degree of detail
as it will be lost in the display.
Example of Logarithm Image
Fourier Spectrum with Result after apply the log
range = 0 to 1.5 x 106 transformation
Power-Law Transformations
s = crγ
c and γ are positive
Output gray level, s
constants
Power-law curves with
fractional values of γ
map a narrow range of
dark input values into a
wider range of output
values, with the opposite
being true for higher
values of input levels.
Input gray level, r
Plots of s = crγ for various values of γ c = γ = 1 D Identity
(c = 1 in all cases) function
Gamma correction
Cathode ray tube (CRT)
devices have an
Monitor
intensity-to-voltage
response that is a
power function, with γ
varying from 1.8 to 2.5
γ = 2.5
Gamma
correction
The picture will become
darker.
Gamma correction is
Monitor
done by preprocessing
the image before
inputting it to the
monitor with s = cr1/γ
γ =1/2.5 = 0.4
a b
Another example : MRI c d
(a) a magnetic resonance image
The picture is dark
(b) result after power-law
transformation with γ = 0.6, c=1
(c) transformation with γ = 0.4
(best result)
(d) transformation with γ = 0.3
(under acceptable level)
Effect of decreasing gamma
When the γ is reduced too much,
the image begins to reduce contrast
to the point where the image
started to have very slight “wash-
out” look, especially in the
background
a b
Another example c d
(a) image has a washed-out
appearance, it needs a
compression of gray levels
D needs γ > 1
(b) result after power-law
transformation with γ = 3.0
(suitable)
(c) transformation with γ = 4.0
(suitable)
(d) transformation with γ = 5.0
(high contrast, the image
has areas that are too dark,
some detail is lost)
Piecewise-Linear
Transformation Functions
Advantage:
Allow more control on the complexity of T(r).
Disadvantage:
Their specification requires considerably more user
input
Contrast stretching.
Gray-level slicing.
Bit-plane slicing.
Contrast Stretching
Increase the dynamic range
of gray levels.
(a) Transformation Function
(b) a low-contrast image :
result from poor
illumination, lack of dynamic
range in the imaging sensor,
or even wrong setting of a
lens aperture of image
acquisition
(c) result of contrast
stretching
(d) result of thresholding
Gray-level slicing
Highlighting a specific
range of gray levels
Display a high value of all
gray levels in the region of
interest and a low value
for all other gray levels
(a) transformation highlights
range [A,B] of gray level and
reduces all others to a
constant level
(b) transformation highlights
range [A,B] but preserves all
other levels
(c) An image.(d) Result of using
the transformation in (a).
Bit-plane slicing
Highlighting the
Bit-plane 7
contribution made to total
One 8-bit byte
(most significant) image appearance by
specific bits
Suppose each pixel is
represented by 8 bits
Higher-order bits contain
the majority of the visually
Bit-plane 0 significant data
(least significant)
Useful for analyzing the
relative importance played
by each bit of the image
Example
The (binary) image for
bit-plane 7 can be
obtained by processing
the input image with a
thresholding gray-level
transformation.
Map all levels between 0
and 127 to 0
Map all levels between 129
and 255 to 255
An 8-bit fractal image
8 bit planes
Bit-plane 7 Bit-plane 6
Bit- Bit- Bit-
plane 5 plane 4 plane 3
Bit- Bit- Bit-
plane 2 plane 1 plane 0