Professional Documents
Culture Documents
Spatial Domain II
Review: gray level transformations
gray level
Obtain contrast information
from histogram
Histogram: implementation issue
Divide the range of gray levels (ex. 0~255)
Number of bins
Position of bins specified in a vector
10 bins
5 bins
Histogram: normalization
uniform
0 1 0 1
Histogram equalization(cont.)
Cumulative function of
1 histogram
Prob. 0.5
0.5
0 1 0 0.5 1
Ideal uniform histogram
Histogram equalization:
discrete solution
Probability (normalized histogram) of gray
level rk
p(rk)=nk/n, k=0,1,2,…, L-1
Discrete version of CDF (cumulative
distribution function)
k k nj
sk T (rk ) pr (rj ) <1
j 0 j 0 n
Example: histogram equalization
Histogram Processing
Histogram equalization
Histogram matching
Local enhancement
Use of histogram statistics
Histogram matching: original
image
Histogram equalization result
Histogram
Equalization
function
Equalized
histogram
After equalization
Histogram matching
The desired shape of histogram is specified
(not necessarily uniform)
Derivation of histogram matching function:
z=G-1(T(r))
z s r
desired uniform input
z=G-1(s) s=T(r)
histogram
equalization
histogram
equalization
s=G(z)
Original -> uniform desire -> uniform
(equalization) (equalization)
Inverse
function
of G
Histogram matching result
Desired histogram
After histogram
matching
G-1
Histogram Processing
Histogram equalization
Histogram matching
Local enhancement
Use of histogram statistics
Local enhancement
Global: entire image
Local: neighborhood of each pixel
mS xy r
( s ,t )S xy
s ,t p(rs ,t ) mean in Sxy
(r )
2
S xy (r
( s ,t )S xy
s ,t mS xy ) p(rs ,t )
2
variance in Sxy
Application of histogram statistics:
example
Globally, this image is light
鎢絲及其支柱的放大影像
Histogram statistics: example
Calculate local statistics in 3x3 region
local mean local standard deviation
Histogram statistics: example
Local enhancement 像素平均值小 但是標準差大
E f ( x, y )k1 if mS xy k0 M G and DG S xy k1 DG
g ( x, y )
f ( x, y ) otherwise
enhanced
pixels
Histogram statistics: example
original enhanced
Outline: spatial domain
Histogram processing
Spatial filtering
Smoothing filter
Ordered statistics filter
Sharpening filter
Basics of spatial filtering
g(x,y)=T[ f(x,y) ]
T operates on a
neighborhood
mask coefficients
X (product) output
underlying neighborhood
Basics of spatial filtering
Mathematical formula
a b
g ( x, y ) w(s, t ) f ( x s, y t )
s at b
convolution
Border issues
Operate inside only
Discard the mask at border
Padding at image boundaries
zero padding
extension
Smoothing spatial filtering
Used for blurring and for noise reduction
Smoothing linear filters
Average filters, low-pass filters
noise
reduced
5x5 9x9
small area
blended into
background
15x15 35x35
border
effects
Smoothing: example
salt-and-pepper noise
Outline: spatial domain
Histogram processing
Spatial filtering 空間濾波
Smoothing filter
Ordered statistics filter
Sharpening filter
Sharpening
filtering:
example
original Edge detection
scaled sharpened
Sharpening spatial filters
Goal
highlight fine detail in an image
Spatial differentiation 微分
Digital implementation => difference 差分
de-emphasize regions with slowly varying gray
levels
smooth
1 ( 1) '
2 ( 1)2 ''
Sharpening: foundation
First and second-order derivatives in digital
form => difference
f
f ( x 1) f ( x) 一次微分
x
2 f
[ f ( x 1) f ( x)] [ f ( x) f ( x 1)] 二次微分
x 2
f ( x 1) f ( x 1) 2 f ( x)
2nd derivatives for image
2-D 2nd derivatives => Laplacian
2
f 2
f
f 2 2
2
x y
=>discrete formulation
2 f [ f ( x 1, y ) f ( x 1, y ) 2 f ( x, y )]
[ f ( x, y 1) f ( x, y 1) 2 f ( x, y )]
[ f ( x 1, y ) f ( x 1, y ) f ( x, y 1) f ( x, y 1)] 4 f ( x, y )
Definition of 2nd derivatives in
filter mask
450 rotation
900 rotation invariant
invariant (include
Diagonals)
- - - -
- 4 - - 8 -
- - - -
Laplacian filtering: example
original Laplacian
scaled sharpened
original
right
left
mask
mask
Use of 1st derivative: Gradient
Gradient f
Gx x
f f
G y
y
Magnitude of gradient
2 1/ 2
f f
2
f mag (f )
x y