Chapter 03 - dcc
-
Upload
srini-vasan -
Category
Documents
-
view
218 -
download
0
Transcript of Chapter 03 - dcc
-
7/30/2019 Chapter 03 - dcc
1/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3
Image Enhancementin the Spatial Domain
-
7/30/2019 Chapter 03 - dcc
2/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Image Enhancement in theSpatial Domain
The spatial domain:
The image plane
For a digital image is a Cartesian coordinate system of discrete rowsand columns. At the intersection of each row and column is a pixel.Each pixel has a value, which we will call intensity.
The frequency domain :
A (2-dimensional) discrete Fourier transform of the spatial domain
We will discuss it in chapter 4.
Enhancement :
To improve the usefulness of an image by using some transformationon the image.
Often the improvement is to help make the image better looking,such as increasing the intensity or contrast.
-
7/30/2019 Chapter 03 - dcc
3/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Background
A mathematical representation ofspatial
domainenhancement:
wheref(x,y): the input image
g(x,y): the processed image
T: an operator onf, defined over some neighborhood of
(x,y)
)],([),( yxfTyxg
-
7/30/2019 Chapter 03 - dcc
4/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Gray-level Transformation
-
7/30/2019 Chapter 03 - dcc
5/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Some Basic Gray Level Transformations
-
7/30/2019 Chapter 03 - dcc
6/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Image Negatives
rLs 1
Let the range of gray level be [0,L-1], then
-
7/30/2019 Chapter 03 - dcc
7/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Log Transformations
)1log( rcs
where c : constant
0r
-
7/30/2019 Chapter 03 - dcc
8/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Power-Law Transformation
crs
where c, : positive constants
-
7/30/2019 Chapter 03 - dcc
9/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Power-Law Transformation
Example 1: Gamma Correction
4.0
-
7/30/2019 Chapter 03 - dcc
10/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Power-Law Transformation
Example 2: Gamma Correction
4.0 3.0
6.01
-
7/30/2019 Chapter 03 - dcc
11/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Power-Law Transformation
Example 3: Gamma Correction
0.3
0.50.4
1
-
7/30/2019 Chapter 03 - dcc
12/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Piecewise-Linear Transformation FunctionsCase 1: Contrast Stretching
-
7/30/2019 Chapter 03 - dcc
13/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Piecewise-Linear Transformation FunctionsCase 2:Gray-level Slicing
An image Result of using the transformation in (a)
-
7/30/2019 Chapter 03 - dcc
14/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Piecewise-Linear Transformation FunctionsCase 3:Bit-plane Slicing
Bit-plane slicing:
It can highlight the contribution made to total image appearance by
specific bits.
Each pixel in an image represented by 8 bits.
Image is composed of eight 1-bit planes, ranging from bit-plane 0 forthe least significant bit to bit plane 7 for the most significant bit.
-
7/30/2019 Chapter 03 - dcc
15/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Piecewise-Linear Transformation FunctionsBit-plane Slicing: A Fractal Image
l d d
-
7/30/2019 Chapter 03 - dcc
16/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Piecewise-Linear Transformation FunctionsBit-plane Slicing: A Fractal Image
2
7 6
45 3
1 0
Di i l I P i 2 d d
-
7/30/2019 Chapter 03 - dcc
17/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Processing
Di it l I P i 2 d d
-
7/30/2019 Chapter 03 - dcc
18/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Processing
Di it l I P i 2 d d
-
7/30/2019 Chapter 03 - dcc
19/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Equalization
Histogram equalization:
To improve the contrast of an image
To transform an image in such a way that the transformed image has a
nearly uniform distribution of pixel values
Transformation: Assume rhas been normalized to the interval [0,1], with r= 0
representing black and r= 1 representing white
The transformation function satisfies the following conditions: T(r) is single-valued and monotonically increasing in the interval
10 r
10for1)(0 rrT
10)( rrTs
Di it l I P i 2 d d
-
7/30/2019 Chapter 03 - dcc
20/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Equalization
For example:
Di it l I P i 2 d d
-
7/30/2019 Chapter 03 - dcc
21/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Equalization
Histogram equalization is based on a transformation of theprobability density function of a random variable.
Letpr(r) andps(s) denote theprobability density function ofrandom variable rands, respectively.
Ifpr(r) and T(r) are known, then the probability densityfunctionps(s) of the transformed variables can be obtained
Define a transformation functionwhere w is a dummy variable of integration
and the right side of this equation is the cumulative distributionfunction of random variable r.
r
r dwwprTs 0 )()(
ds
drrpsp rs )()(
Di it l I P i 2 d d
-
7/30/2019 Chapter 03 - dcc
22/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Equalization
Given transformation function T(r),
ps(s) now is a uniform probability density function.
T(r) depends onpr(r), but the resultingps(s) always is uniform.
101)(
1)()()( srp
rpdsdrrpsp
r
rrs
)()()(
0rpdwwp
dr
d
dr
rdT
ds
drr
r
r
r
r dwwprT0
)()(
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
23/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Equalization
In discrete version:
The probability of occurrence of gray level rkin an image is
n : the total number of pixels in the imagenk: the number of pixels that have gray level rkL : the total number of possible gray levels in the image
The transformation function is
Thus, an output image is obtained by mapping each pixel with level rkin the input image into a corresponding pixel with levelsk.
1,...,2,1,0)()(0 0
LknnrprTs
k
j
k
j
j
jrkk
1,...,2,1,0)( Lkn
nrp kr
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
24/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Equalization
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
25/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Equalization
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
26/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Equalization
Transformation functions (1) through (4) were obtained form the
histograms of the images in Fig 3.17(1), using Eq. (3.3-8).
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
27/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Histogram Matching
Histogram matching is similar to histogram equalization,
except that instead of trying to make the output image have a
flat histogram, we would like it to have a histogram of a
specified shape, saypz(z).
We skip the details of implementation.
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
28/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Local Enhancement
The histogram processing methods discussed above are global,
in the sense that pixels are modified by a transformation
function based on the gray-level content of an entire image.
However, there are cases in which it is necessary to enhance
details oversmall areas in an image.
original global local
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
29/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Use of Histogram Statistics for Image Enhancement
Moments can be determined directly from a histogram much faster than
they can from the pixels directly.
Let rdenote a discrete random variable representing discrete gray-levels in
the range [0,L-1], andp(ri) denote the normalized histogram component
corresponding to the ith value ofr, thenthe nth moment ofrabout its mean
is defined as
where m is the mean value ofr
For example, the second moment (also the variance ofr) is
1
0
)(L
i
ii rprm
1
0
2
2 )()()(L
i
ii rpmrr
1
0
)()()(L
i
i
n
in rpmrr
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
30/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Use of Histogram Statistics for Image Enhancement
Two uses of the mean and variance for enhancement
purposes:
The global mean and variance (global means for the entire
image) are useful for adjusting overall contrast andintensity.
The mean and standard deviation for a local region are
useful for correcting for large-scale changes in intensity
and contrast. ( See equations 3.3-21 and 3.3-22.)
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
31/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Use of Histogram Statistics for Image EnhancementExample: Enhancement based on local statistics
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
32/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Use of Histogram Statistics for Image EnhancementExample: Enhancement based on local statistics
Digital Image Processing 2nd ed
-
7/30/2019 Chapter 03 - dcc
33/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Use of Histogram Statistics for Image EnhancementExample: Enhancement based on local statistics
Digital Image Processing, 2nd ed.
-
7/30/2019 Chapter 03 - dcc
34/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Enhancement Using Arithmetic/Logic Operations
Two images of the same size can be combined using
operations of addition, subtraction, multiplication, division,
logical AND, OR, XOR and NOT. Such operations are done
on pairs of theircorresponding pixels.
Often only one of the images is a real picture while the other is
a machine generated mask. The mask often is a binary image
consisting only of pixel values 0 and 1. Example: Figure 3.27
Digital Image Processing, 2nd ed.
-
7/30/2019 Chapter 03 - dcc
35/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Enhancement Using Arithmetic/Logic Operations
AND
OR
Digital Image Processing, 2nd ed.
-
7/30/2019 Chapter 03 - dcc
36/61
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Image SubtractionExample 1
Digital Image Processing, 2nd ed.
-
7/30/2019 Chapter 03 - dcc
37/61
igital mage rocessing, nd ed.www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Image SubtractionExample 2
When subtracting two images, negative pixel values can result.So, if you want to display the result it may be necessary toreadjust the dynamic range by scaling.
Digital Image Processing, 2nd ed.i i b k
-
7/30/2019 Chapter 03 - dcc
38/61
g g g,www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Image Averaging
When taking pictures in reduced lighting (i.e., lowillumination), image noise becomes apparent.
A noisy imageg(x,y) can be defined by
wheref(x,y): an original image
: the addition of noise
One simple way to reduce this granular noise is to takeseveral identical pictures and average them, thussmoothing out the randomness.
),(),(),( yxyxfyxg
),( yx
Digital Image Processing, 2nd ed.i i b k
-
7/30/2019 Chapter 03 - dcc
39/61
g g g,www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Noise Reduction by Image AveragingExample: Adding Gaussian Noise
Figure 3.30 (a): An image
of Galaxy Pair NGC3314.
Figure 3.30 (b): Image
corrupted by additive
Gaussian noise with zeromean and a standard
deviation of 64 gray
levels.
Figure 3.30 (c)-(f):
Results of averagingK=8,16,64, and 128 noisy
images.
Digital Image Processing, 2nd ed.i i b k
-
7/30/2019 Chapter 03 - dcc
40/61
g g g,www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Noise Reduction by Image AveragingExample: Adding Gaussian Noise
Figure 3.31 (a):
From top to bottom:
Difference images
between Fig. 3.30 (a)
and the four images in
Figs. 3.30 (c) through
(f), respectively.
Figure 3.31 (b):Corresponding
histogram.
Digital Image Processing, 2nd ed.www imageprocessingbook com
-
7/30/2019 Chapter 03 - dcc
41/61
g g g,www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Basics of Spatial Filtering
In spatial filtering (vs. frequency domain filtering), the output image is
computed directly by simple calculations on the pixels of the input image.
Spatial filtering can be either linear or non-linear.
For each output pixel, some neighborhood of input pixels is used in the
computation.
In general, linear filtering of an imagefof sizeMXNwith a filter mask of
size mxn is given by
where a=(m-1)/2 and b=(n-1)/2
This concept called convolution. Filter masks are sometimes called
convolution masks orconvolution kernels.
a
as
b
bt
tysxftswyxg ),(),(),(
Digital Image Processing, 2nd ed.www imageprocessingbook com
-
7/30/2019 Chapter 03 - dcc
42/61
g g gwww.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Basics of Spatial Filtering
Digital Image Processing, 2nd ed.www imageprocessingbook com
-
7/30/2019 Chapter 03 - dcc
43/61
g g gwww.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Nonlinear spatial filtering usually uses a neighborhood too, but
some other mathematical operations are use. These can
include conditional operations (if , then), statistical
(sorting pixel values in the neighborhood), etc.
Because the neighborhood includes pixels on all sides of thecenter pixel, some special procedure must be used along the
top, bottom, left and right sides of the image so that the
processing does not try to use pixels that do not exist.
Basics of Spatial Filtering
Digital Image Processing, 2nd ed.www imageprocessingbook com
-
7/30/2019 Chapter 03 - dcc
44/61
g g gwww.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Smoothing Spatial Filters
Smoothing linear filters
Averaging filters (Lowpass filters in Chapter 4))
Box filter
Weighted average filter
Box filter Weighted average
Digital Image Processing, 2nd ed.www imageprocessingbook com
-
7/30/2019 Chapter 03 - dcc
45/61
g g gwww.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Smoothing Spatial Filters
The general implementation for filtering anMXNimage with
a weighted averaging filter of size mxn is given by
where a=(m-1)/2 and b=(n-1)/2
a
as
b
bt
a
as
b
bt
tsw
tysxftsw
yxg
),(
),(),(
),(
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
46/61
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Smoothing Spatial FiltersImage smoothing with masks of various sizes
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
47/61
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Smoothing Spatial FiltersAnother Example
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
48/61
g p g
2002 R. C. Gonzalez & R. E. Woods
Order-Statistic Filters
Order-statistic filters
Median filter: to reduce impulse noise (salt-and-
pepper noise)
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
49/61
g p g
2002 R. C. Gonzalez & R. E. Woods
Sharpening Spatial Filters
Sharpening filters are based on computing spatial
derivatives of an image.
The first-order derivative of a one-dimensional
functionf(x) is
The second-order derivative of a one-dimensional
functionf(x) is
)()1( xfxfxf
)(2)1()1(2
2
xfxfxfxf
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
50/61
g p g
2002 R. C. Gonzalez & R. E. Woods
Sharpening Spatial FiltersAn Example
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
51/61
2002 R. C. Gonzalez & R. E. Woods
Use of Second Derivatives for EnhancementThe Laplacian
Development of the Laplacian method
The two dimensional Laplacian operator for continuous
functions:
The Laplacian is a linear operator.
2
2
2
22
y
f
x
ff
),(2),1(),1(2
2
yxfyxfyxfx
f
),(2)1,()1,(2
2
yxfyxfyxfyf
)(4)]1,()1,(),1(),1([2 xfyxfyxfyxfyxff
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
52/61
2002 R. C. Gonzalez & R. E. Woods
Use of Second Derivatives for EnhancementThe Laplacian
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
53/61
2002 R. C. Gonzalez & R. E. Woods
Use of Second Derivatives for EnhancementThe Laplacian
To sharpen an image, the Laplacian of the image is subtracted
from the original image.
Example: Figure 3.40
positive.ismaskLaplaciantheoftcoefficiencentertheif),(
negative.ismaskLaplaciantheoftcoefficiencentertheif),(),(
2
2
fyxf
fyxfyxg
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
54/61
2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
55/61
2002 R. C. Gonzalez & R. E. Woods
Use of Second Derivatives for EnhancementThe Laplacian: Simplifications
The g(x,y) mask
Not only f2
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
56/61
2002 R. C. Gonzalez & R. E. Woods
Use of First Derivatives for EnhancementThe Gradient
Development of the Gradient method
The gradient of functionfat coordinates (x,y) is defined as
the two-dimensional column vector:
The magnitude of this vector is given by
y
fx
f
G
G
y
xf
2
1
22
2
122)(mag
y
f
x
fGGf yxf
yx GGf
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
57/61
2002 R. C. Gonzalez & R. E. Woods
Use of First Derivatives for EnhancementThe Gradient
Roberts cross-gradient
operators
Sobel
operators
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
58/61
2002 R. C. Gonzalez & R. E. Woods
Use of First Derivatives for EnhancementThe Gradient: Using Sobel Operators
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
59/61
2002 R. C. Gonzalez & R. E. Woods
Combining SpatialEnhancement Methods
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
60/61
2002 R. C. Gonzalez & R. E. Woods
Combining SpatialEnhancement Methods
Digital Image Processing, 2nd ed.www.imageprocessingbook.com
-
7/30/2019 Chapter 03 - dcc
61/61