Professional Documents
Culture Documents
Chapter 03 Image Enhcancement Spatial Domain
Chapter 03 Image Enhcancement Spatial Domain
CCU, Taiwan
Wen-Nung Lie
Backgrounds
Spatial domain methods are procedures that operate
directly on pixels
g ( x, y ) = T [ f ( x, y )]
Neighborhood about a point (x,y)
Neighborhood = 1×1Æ point processing or contrast stretching
Larger neighborhood Æ mask processing
CCU, Taiwan
Wen-Nung Lie 3-1
Some basic point
transformations
Implemented by look-up
tables
Functions
Linear (negative and
identity)
Logarithmic (log and
inverse log)
s = c log(1 + r )
Power-law (nth power and
nth root)
s = cr γ or s = c( r + ε ) γ
CCU, Taiwan
Wen-Nung Lie 3-2
Log transform
Expand the dynamic range of low gray-levels values
Compress the dynamic range of images with large variations in
pixel values
Power-law transformation
Curves generated with γ > 1 have exactly the opposite effect as
those generated with γ < 1
CCU, Taiwan
Wen-Nung Lie 3-3
Gamma correction
A variety of devices used for image capture,
printing, and display respond according to a power
law
The process used to correct the power-law
response phenomena is called gamma correction
CRT has an intensity-to-voltage response of γ = 1.8 ~ 2.5
Æ produce images that are darker1 than intended
Æ preprocess the images with γ 2.5 = γ 0.4 before
inputting it into the monitor
Current image standards do not contain the value
of gamma with which an image was created
CCU, Taiwan
Wen-Nung Lie 3-4
CCU, Taiwan
Wen-Nung Lie 3-5
Power-law transformation for
contrast manipulation
CCU, Taiwan
Wen-Nung Lie 3-6
Piecewise-linear
transformation
The form of piecewise functions can be arbitrarily complex
Contrast stretching – increase the dynamic range of images
being processed
CCU, Taiwan
Wen-Nung Lie 3-7
Graylevel slicing & bit-plan
slicing
CCU, Taiwan
Wen-Nung Lie 3-8
Bit-plane decomposition
CCU, Taiwan
Wen-Nung Lie 3-10
Histogram equalization
Point transformation
s = T (r ), 0 ≤ r ≤1
Single-valued
Monotonically increasing
dr
p s ( s ) = pr ( r )
ds
ps ( s ) = 1, 0 ≤ s ≤1 Uniform distribution
Discrete implementation
k n k
s = T (r ) = ∑ p (r ) = ∑ , k = 0,1,..., L − 1
j
k k r j
j =0 n j =0
CCU, Taiwan
Wen-Nung Lie 3-13
Histogram matching
(specification)
Transform the image such that it has an
approximately desired histogram shape
Given pr (rk ) and p z ( z j ) (input and desired output),
compute
k h
sk = ∑ pr ( r j ) vh = ∑ p z ( z j )
j =0 j =0
result
CCU, Taiwan
Wen-Nung Lie 3-23
Linear spatial filtering
a b
g ( x, y ) = ∑ ∑ w( s , t ) f ( x + s , y + t )
s = − at = − b
CCU, Taiwan
Wen-Nung Lie 3-24
Smoothing spatial filter
Used for blurring and noise reduction
Also called averaging filter or lowpass filter
Two 3×3 examples
The division scale factor is equal to sum of the coefficients
(avoiding overflow) and had better be a power of 2
weighted average
the weight decreases as the distance to the center pixel increases
Discrete Gaussian averaging with variance σ
2
a b
1 1 1 1 2 1
∑ ∑ w( s , t ) f ( x + s , y + t )
1/9 1 1 1 1/16 2 4 2 g ( x, y ) = s = − at = − b
a b
1 1 1 1 2 1 ∑ ∑ w( s , t )
s = − at = − b
CCU, Taiwan
Wen-Nung Lie 3-25
More larger the window, more blurring effect it has
More flat the coefficients are, more blurring they result in
CCU, Taiwan
Wen-Nung Lie 3-26
Order-statistics (Median) filter
Nonlinear spatial filter whose response is based on
ordering (ranking) the pixels contained in the window
effective to eliminate impulse noise or salt-and-pepper noise,
with considerably less blurring than linear smoothing filter
eliminate noise less than half of the window size
1-D or 2-D window size
CCU, Taiwan
Wen-Nung Lie 3-28
2nd-order derivative --
Laplacian operator
Isotropic filter -- whose response is independent of the
direction of the discontinuities in the image, or rotation-
invariant
The Laplacian is the simplest isotropic derivative operator
∂2 f ∂2 f
∇ f = 2 + 2
2
0 -1 0 -1 -1 -1
∂x ∂y
-1 4 -1 -1 8 -1
∂2 f
= f ( x + 1, y ) + f ( x − 1, y ) − 2 f ( x, y )
∂x 2
0 -1 0 -1 -1 -1
∂2 f
= f ( x, y + 1) + f ( x, y − 1) − 2 f ( x, y ) Digital Laplacian
∂y 2
∇ 2 f = [ f ( x + 1, y ) + f ( x − 1, y ) + f ( x, y + 1) + f ( x, y − 1)] − 4 f ( x, y )
CCU, Taiwan
Wen-Nung Lie 3-29
Use of Laplacian for
sharpening enhancement
Sharpening enhancement -- add the Laplacian response to
the original image
g ( x, y ) = f ( x, y ) ± ∇ 2 f ( x, y )
g ( x, y ) = f ( x, y ) + ∇ 2 f ( x, y )
0 -1 0 = 5 f ( x, y ) − [ f ( x + 1, y ) + f ( x − 1, y )
-1 5 -1 + f ( x, y + 1) + f ( x, y − 1)]
0 -1 0
-1 -1 -1
-1 9 -1
0 -1 0 -1 -1 -1 The sharpening
-1 A+4 -1 -1 A+8 -1
effect decreases as
A increases
0 -1 0 -1 -1 -1
CCU, Taiwan
Wen-Nung Lie 3-31
Application of high-boost
filtering
Sharpen the image and simultaneously
brighten it
CCU, Taiwan
Wen-Nung Lie A=1 A=1.7 3-32
Use of 1st-order derivative
Gradient vector ⎡ ∂f ⎤
⎡Gx ⎤ ⎢ ∂x ⎥
∇f = ⎢ ⎥ = ⎢ ∂f ⎥
⎣G y ⎦ ⎢ ⎥
⎢⎣ ∂y ⎥⎦
Gradient magnitude
1
∇f = mag (∇f ) = [G + G ]2
x
2 2
y
∂f 2 ∂f 2 12
= [( ) + ( ) ]
Approximation ∂x ∂y
∇f ≈ G x + G y
CCU, Taiwan
Wen-Nung Lie 3-33
Popular gradient operators
-1 0 0 -1
Roberts cross-gradient operators
0 1 1 0
Sobel gradient operator
-1 -2 -1 -1 0 1 The coefficients sum to zero, to
0 0 0 -2 0 2
yield zero on flat areas
1 2 1 -1 0 1
CCU, Taiwan
Wen-Nung Lie Laplacian operator Sobel operator 3-34
Combining spatial
enhancement methods
Use Laplacian to highlight fine detail
also produce noiser results than the gradient
Use gradient to enhance prominent edges
The gradient has a stronger response in ramps and steps areas than
does the Laplacian
The response of the gradient to noise is lower than Laplacian
The response to noise can be lowered by smoothing the gradient
with an averaging filter
Combining Laplacian and gradient operators
smooth the gradient and multiply it by the Laplacian image
(preserve details in the strong areas while reducing noise in the flat
areas)
The above result is added to the original image
CCU, Taiwan
Wen-Nung Lie 3-35
Smoothed gradient Product of Laplacian
original Laplacian by 5x5 window and smoothed gradient