Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Ch03_Spatial Domain Image Processing (1)

Chapter Three discusses spatial domain image processing, focusing on intensity transformations and spatial filtering techniques. It covers various methods such as contrast stretching, histogram equalization, and different types of spatial filters, including linear and nonlinear filters. The chapter emphasizes the mathematical foundations and applications of these techniques in enhancing image quality.

Uploaded by

edendebebe72
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Ch03_Spatial Domain Image Processing (1)

Chapter Three discusses spatial domain image processing, focusing on intensity transformations and spatial filtering techniques. It covers various methods such as contrast stretching, histogram equalization, and different types of spatial filters, including linear and nonlinear filters. The chapter emphasizes the mathematical foundations and applications of these techniques in enhancing image quality.

Uploaded by

edendebebe72
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

Chapter Three

Spatial Domain Image Processing

1
3.1. Spatial Processing of Digital
Images
 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.
 Two principal categories of spatial processing
are intensity transformations and spatial
filtering.
 Intensity transformations operate on single
pixels of an image for tasks such as contrast
manipulation and image thresholding.
2
…cont’d

 Spatial filtering performs operations on the


neighborhood of every pixel in an image.
Examples of spatial filtering include image
smoothing and sharpening.

3
The Basics of Intensity Transformations
and Spatial Filtering

 The spatial domain processes are


mathematically expressed as:

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
…cont’d

 Figure shows the basic implementation of the


above equation on a single image.

5
…cont’d

 The process that the above figure illustrates


consists of moving the center of the
neighborhood from pixel to pixel, and
applying the operator T to the pixels in the
neighborhood to yield an output value at that
location.
 Thus, for any specific location (x0,y0), the
value of the output image g at those
coordinates is equal to the result of applying
T to the neighborhood with origin at (x0,y0)in f.
6
…cont’d

 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, s and r to denote the intensity of g
and f respectively at any point (x,y).

7
…cont’d

 For example, contrast stretching and


thresholding function.

Contrast stretching Thresholding


8
…cont’d

 Contrast stretching is a linear mapping


function used to manipulate the contrast of an
image.
 Thresholding produces a binary image

9
3.2. Basic Intensity Transformation
Functions
 There are three basic types of intensity
transformation functions:
 Linear (negative and identity transformations),
 Logarithmic (log and inverse-log
transformations), and
 Power-law (nth power and nth root
transformations).
 The identity function is the trivial case in which
the input and output intensities are identical.

10
…cont’d

11
Image Negatives

 The negative of an image with intensity levels


in the range [ 0, L-1] is obtained by using the
negative transformation function which has
the form: s = L – 1 – r
 This type of processing is used, for example,
in enhancing white or gray detail embedded
in dark regions of an image, especially when
the black areas are dominant in size.

12
…cont’d

Image Negative Image

13
Log Transformations

 The general form of the log transformation in


is s = c log(1 + r)
where c is a constant and it is assumed that r ≥ 0.
 The logarithmic (log) transformation is used to
compress the dynamic range of an image.
 Log transformation maps a narrow range of
low intensity values in the input into a wider
range of output levels and the opposite is true
for higher values of input grayscale levels.

14
…cont’d

 In other words, values of dark pixels in an


image are expanded, while the high
grayscale values are compressed.
 The inverse log transformation does the
opposite.
 As shown in Figure, log transformation is
used to view Fourier transformed images, as
their dynamic ranges are very high.
 Log transformations show the details that are
not visible due to a large dynamic range of
pixel values. 15
…cont’d

Fourier spectrum displayed as a Result of applying the log


grayscale image. transformation with c = 1

16
Power-law (Gamma)
Transformations
 Power-law transformations have the form

where c and are positive constants.


 As with log transformations, 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.

17
…cont’d

 Power-law transformations are useful for


general-purpose contrast manipulation.

18
Piecewise Linear Transformation
Functions
 Complementary approach to Linear,
Logarithmic, and Power-law transformations.
 The advantage of these functions is that the
form of piecewise functions can be arbitrarily
complex.
 The main disadvantage of these functions is
that their specification requires considerable
user input.
 Example: Contrast Stretching, Intensity-Level
Slicing, Bit-Plane Slicing
19
Contrast Stretching
 Low-contrast images can result from poor
illumination, lack of dynamic range in the
imaging sensor, or even 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.

20
…cont’d

Piecewise linear A low contrast Result of


transformation electron image contrast stretching.
function.

Contrast stretching is obtained by setting (r1 , s1) = (rmin, 0) and (r2


, s2 ) = (rmax, L-1), where rmin and rmax denote the minimum and
maximum intensity levels in the input image 21
Intensity-Level Slicing
 Highlight a specific range of intensities in an
image.
 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.
 This transformation, produces a binary image.
22
…cont’d

 The second approach, brightens (or darkens)


the desired range of intensities, but leaves all
other intensity levels in the image unchanged.

Original First approach Second approach


23
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,
Bit-Plane Slicing highlight the contribution
made to total image appearance by specific
bits.

24
Bit-planes of an 8-bit image.
…cont’d

25
3.3 Histogram Processing

Image Histogram
 An image histogram is a type of histogram that
acts as a graphical representation of the tonal
distribution in a digital image.
 It plots the number of pixels for each tonal
value
 The horizontal axis of the graph represents the
tonal variations, while the vertical axis
represents the total number of pixels in that
particular tone.
26
…cont’d

Image

27
Image Histogram
…cont’d

 Let rk, for k = 0 1 2 ,…, L - 1 denote the


intensities of an L-level digital image, f(x, y).
 The unnormalized histogram of f is defined as

where nk is the number of pixels in f with


intensity rk, and the subdivisions of the
intensity scale are called histogram bins.
 The normalized histogram of f is defined as

Where, M = image rows and N = image columns 28


…cont’d

 Normalized histogram referred to as


histograms or image histograms.
 The sum of p(rk) for all values of k is always 1.
 Histogram shape is related to image
appearance.

29
Histogram Equalization

 Histogram equalization is used for equalizing


all the pixel values of an image.
 Transformation is done in such a way that
uniform flattened histogram is produced.
 Histogram equalization increases the
dynamic range of pixel values and makes an
equal count of pixels at each level which
produces a flat histogram with high contrast
image.

30
…cont’d

Before equalization After equalization


31
 For continuous intensity value, a histogram
equalization or histogram linearization
transformation is given by:

where L is the number of possible intensity levels


in the image and the integral on the right side is
the cumulative distribution function (CDF) of
random variable r.
 Recall that the probability of occurrence of
intensity level rk in a digital image is
approximated by:
32
…cont’d

• For discrete intensity value, a histogram


equalization or histogram linearization
transformation is given by:

33
3.4 Spatial Filtering

 Filter is the process that moves some


unwanted components or small details in an
image.
 Spatial filtering modifies an image by
replacing the value of each pixel by a function
of the values of the pixel and its neighbors.
 There are two types of spatial filtering:
 Linear spatial filter – the operation performed
on the image pixels is linear
 Nonlinear spatial filter the operation performed
on the image pixels is nonlinear 34
Linear spatial filtering

 A linear spatial filter performs a sum-of-


products operation between an image f and a
filter kernel (mask), w.
 The kernel is an array whose size defines the
neighborhood of operation, and whose
coefficients determine the nature of the filter.
 The filter mask may be 3x3, 5x5, or 7x7 mask
 At any point (x, y) in the image, the response,
g(x, y), of the filter is the sum of products of
the kernel coefficients and the image pixels
encompassed by the kernel: 35
…cont’d

 In general, linear spatial filtering of an image


of size M x N with a kernel of size m x n is
given by the expression:

 For a kernel of size m x n , we assume that


m=2a +1 and n=2b+1, where a and b are
nonnegative integers. 36
…cont’d

37
Spatial Correlation and
Convolution
 Correlation consists of moving the center of a
kernel over an image, and computing the sum
of products at each location.
 Spatial convolution are the same, except that
the correlation kernel is rotated by 180°.
 The correlation of a kernel w of size m x n
with an image f(x,y), is given by

38
…cont’d

 In a similar manner, the convolution of a


kernel w of size m n × with an image f(x,y), is
defined as

39
Types of Spatial Filter

 Spatial filters can be classified by effect into:


 Smoothing spatial filters – also called lowpass
filters
 Sharpening spatial filters – also called
highpass filters

40
Smoothing spatial filters

 Smoothing filters are used for blurring and for


nose reduction.
 Blurring used as preprocessing such as
removal of small details from image.
 Noise reduction is blurring with linear or
nonlinear filter.
 Smoothing filters include:
 Averaging
 Order statistics(non linear)
41
Lowpass Box Filter Kernels

 The simplest, lowpass filter kernel is the box


kernel, whose coefficients have the same
value (typically 1).
 An mxn box filter is an mxn array of 1’s, with
a normalizing constant in front, whose value
is 1 divided by the sum of the values of the
coefficients (i.e., 1/mn when all the
coefficients are 1’s).

3x3 box kernel 42


…cont’d

Origil Image Filtered image 3x3

Filtered Image Filtered image


11x11 21x21

Image averaging 43
Lowpass Gaussian Filter Kernels

 Gaussian kernels is obtained by:

 A 3x3 guassian kernel for K = 1 and

44
…cont’d

(a) A test pattern of size 1024x1024. (b) Result of


lowpass filtering the pattern with a Gaussian kernel of
size 21x21 , with (c) Result of using a kernel of
size 43x43, with

45
Order-statistic (Nonlinear) Filters

 Order-statistic filters are nonlinear spatial


filters whose response is based on ordering
(ranking) the pixels contained in the region
encompassed by the filter.
 Smoothing is achieved by replacing the value
of the center pixel with the value determined
by the ranking result.
 It includes:
 Median filters
 Min filters
 Max filters 46
…cont’d
Median filter
 Replaces the value of the center pixel by the
median of the intensity values in the
neighborhood of that pixel
 It is best for noise reduction
Max filter
 Useful for finding the brightest points in an
image or for eroding dark areas adjacent to
light regions.
 Replaces the value of the center pixel by the
maximum of the intensity values in the
47
…cont’d

Min filter
 Replaces the value of the center pixel by the
minimum of the of the intensity values in the
neighborhood of that pixel
 Useful for finding the darkest points in an
image

48
Sharpening Spatial Filters

 Sharpening highlights transitions in intensity.


 Applicable in:
 Electronic printing,
 Medical imaging,
 Industrial inspection, and
 Autonomous guidance in military systems.

49
Foundations

 Sharpening filters are based on first- and


second-order derivatives
First Derivative:
 Must be zero in areas of constant intensity.
 Must be nonzero at the onset of an intensity
step or ramp.
 Must be nonzero along intensity ramps.
 A basic definition of the first-order derivative of
a one-dimensional function f(x) is the
difference
50
…cont’d

Second Derivatives:
 Must be zero in areas of constant intensity.
 Must be nonzero at the onset and end of an
intensity step or ramp.
 Must be zero along intensity ramps.
 We define the second-order derivative of f(x )
as the difference

51
…cont’d

52
Image Sharpening – the Laplacian

 This approach uses the second order


derivatives for constructing a filter mask
(kernel)
 The Laplacian for the image function f(x,y) is

 In the x-direction, we have

 In the y- direction, we have


53
…cont’d

 It follows from the preceding three equations


that the discrete Laplacian of two variables is

(a) (b) (c) (d)

Laplacian Kernels
54
…cont’d

 If a negative center coefficient is used , then


we subtract the Laplacian image from the
original to obtain a sharpened result.
 Thus, the basic way in which we use the
Laplacian for image sharpening is

where f(x,y) and g(x,y) are the input and


sharpened images, respectively. We let c = −1 if
the Laplacian kernels in above figure (a) or (b) is
used, & c = 1 if either of the other two kernels is
used. 55
…cont’d

Original image Laplacian image


using kernel (a)

Image sharpend Image with


using c = -1 kernel (B)

56
Image Sharpening – the Gradient

 First derivatives in image processing are


implemented using the magnitude of the
gradient.
 The gradient of an image f at coordinates
(x,y) is defined as the two dimensional
column vector

57
…cont’d

 The magnitude (length) of vector , denoted


as M(x,y) (the vector norm notation is also
used frequently), where

is the value at (x,y) of the rate of change in the


direction of the gradient vector.
 M(x,y) is an image of the same size as the
original, created when x and y are allowed to
vary over all pixel locations in f. It is called
gradient image
58

You might also like