Chapter 3
Chapter 3
Chapter 3
Chapter - 3
Spatial Domain Image Processing
By Diriba Regasa (MSc)
Spatial Processing of Digital Images
2
…
3
Basic Intensity Transformation Functions
• The spatial domain processes we discuss in this chapter are based on the
expression g(x, y) = T[f(x, y)] where f(x, y) is an input image, g(x, y) is the
output image, and T is an operator on f defined over a neighborhood of
point (x, y).
• The operator can be applied to the pixels of a single image or to the pixels
of a set of images.
4
…
• The smallest possible neighborhood is of size 1x1. In this case, g
depends only on the value of f at a single point (x, y) and T becomes
an intensity (also called a gray-level, or mapping) transformation
function of the form
» S = T(r)
• where, we use s and r to denote, respectively, the intensity of g and f
at any point (x, y).
• The result of applying the transformation to every pixel in f to
generate the corresponding pixels in g would be to produce an
image of higher contrast than the original, by darkening the intensity
levels below k and brightening the levels above k. This technique
called contrast stretching
• T(r) produces a two level (binary) image. A mapping of this form is
called a thresholding function.
5
…
6
…
• Intensity transformations are among the simplest of all image
processing techniques.
• we denote the values of pixels, before and after processing, by
r and s, respectively.
• These values are related by a transformation T, that maps a
pixel value r into a pixel value s.
• Because we deal with digital quantities, values of an intensity
transformation function typically are stored in a table, and the
mappings from r to s are implemented via table lookups.
• For an 8-bit image, a lookup table containing the values of T
will have 256 entries.
7
…
• Three basic intensity transformation functions used frequently in image
processing:
– linear (negative and identity transformations)
– logarithmic (log and inverse-log transformations)
– power-law (nth power and nth root transformations).
• The identity function is the trivial case in which the input and output
intensities are identical.
9
…
10
Log Transformations
• The general form of the log transformation
» s = clog(1+r)
Where c is a constant, and r ≥ 0
• Log curve maps a narrow range of low gray-level values in
the input image into a wider range of the output levels.
• Used to expand the values of dark pixels in an image while
compressing the higher-level values.
• It compresses the dynamic range of images with large
variations in pixel values.
• Log functions are particularly useful when the input grey
level values may have an extremely large range of values
11
…
12
Power-law (gamma) transformations
• Power-law (gamma) transformations can be mathematically
expressed as
».
• Gamma correction is important for displaying images on a
screen correctly to prevent bleaching or darkening of images
when viewed from different types of monitors with different
display settings.
• This is done because our eyes perceive images in a gamma-
shaped curve, whereas cameras capture images in a linear
fashion.
13
Histogram of images
• The histogram of a digital image with gray levels in the
range [0, L-1] is a discrete function.
• Histogram Function:
• =
• Points about Histogram:
• Histogram of an image provides a global description of the
appearance of an image.
• Information obtained from histogram is very large in quality.
• Histogram of an image represents the relative frequency of
occurrence of various gray levels in an image.
14
…
• Let’s assume that an Image matrix is given as:
• This image matrix contains the pixel values at (i, j) position in
the given x-y plane which is the 2D image with gray levels.
15
…
• There are two ways to plot a Histogram of an image:
• Method 1: In this method, the x-axis has grey levels/ Intensity
values and the y-axis has the number of pixels in each grey level.
The Histogram value representation of the above image is:
Explanation:
The above image has 1, 2, 3, 4, 5, 6, and 8 as
the intensity values and the occurrence of
each intensity value in the image matrix is 2,
1, 3, 2, 2, 3 and 3 respectively so according to
intensity value and occurrence of that
particular intensity we mapped them into a
Graph.
16
…
• Method 2: In this method, the x-axis represents the grey level,
while the y-axis represents the probability of occurrence of that grey
level.
• Probability Function:
•
• Below table shows the probability of each intensity level of an pixel
17
…
• Now we can create a histogram graph for each pixel and
corresponding occurrence probability.
18
Spatial filtering
19
Histogram processing
• Let , for k = 0, 1, 2, 3,… L -1, denote the intensities of an L-
level digital image, f(x, y). The un-normalized histogram of f
is defined as
= for k = 0, 1, 2, 3, … L-1
where is the number of pixels in f with intensity , and the
subdivisions of the intensity scale are called histogram bins.
• Similarly, the normalized histogram of f is defined as
20
…
• Histogram shape is related to image appearance.
• For example: Fig. below shows images with four basic
intensity characteristics: dark, light, low contrast, and high
contrast, the image histograms are also shown.
• In the dark image that the most populated histogram bins are
concentrated on the lower (dark) end of the intensity scale.
• Similarly, the most populated bins of the light image are
biased toward the higher end of the scale.
• An image with low contrast has a narrow histogram located
typically toward the middle of the intensity scale, as Fig. c.
21
…
Four image types and their corresponding histograms. Dark, light, low contrast
and high contrast respectively. The horizontal axis of the histograms are values
of and the vertical axis are values of )
22
Combining Spatial Enhancement Methods
• In this section, illustrate how to combine several approaches
developed to address a difficult image enhancement task.
• Successful image enhancement is typically not achieved using
a single operation.
• Rather we combine a range of techniques in order to achieve a
final result This example will focus on enhancing the bone
scan to the right
23
…
24
…
(e) Sobel image smoothed with a (f) Mask image formed by the
5 5 × box filter product of (b) and (e).
26
…
28
The End