Intensity Transformations, Spatial Fil i Hi P iFiltering ...fac.ksu.edu.sa/sites/default/files/topic2_ch3.pdfIntensity Transformations, Spatial Fil i Hi P iFiltering, Histogram Processing
Post on 03-Aug-2020
0 Views
Preview:
Transcript
Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram Processing
)],([),( yxfTyxg =
Input imageOutput image
Operator
Spatial filtering: Operator isapplied on the neighbors of alocation (origin); then the origin islocation (origin); then the origin ismoved to a new location and theoperation is repeated.
1
Intensity Transfer Functions y
Contrast stretching function. Thresholding function.
r: intensity variable of input image.
2
s: intensity variable of output image.
Basic Intensity Transfer Functions y
• Linear• Logarithmicoga c• Power‐law
3
Negative Transformation gIntensity level: [0, L - 1]
rLs −−= 1
4Original Image Negative Image
Log Transformation g)1log( rcs +=
Compresses the dynamic range of images with large variations in pixel values.
Loss of details in low pixel valuesLoss of details in low pixel values
5Original Image (Fourier Spectrum) Log Transformed Image
Power-Law (Gamma) Transformation ( )γcrs =
6
Gamma Correction Process used to correct power-law response phenomena.
Example: CRT monitor.
Tends to produce images darker.
Decrease value of γ
Solution
Decrease value of γ
7
Example: storing images in web sites.
Contrast manipulation: Power-Lawp
MRI of a fracturedspine. 6.0=λ
30λ40λ 3.0=λ4.0=λ
Best contrast Washed out
8
Best contrast Washed out
Piecewise-Linear Transform FunctionsContrast Stretching
Expands range of intensity level of an image to full intensity range of a device.Expands range of intensity level of an image to full intensity range of a device.
Low-contrast IImage
)0,(),( 11 = msr)1()(
)0,(),( min11 =L
rsr
ThresholdingContrast stretched image
)1,(),( 22 −= Lmsr)1,(),( max22 −= Lrsr
9
g
Piecewise-Linear Transform FunctionsIntensity-Level Slicing
Highlighting a specific range of intensities.Highlighting a specific range of intensities.
Binary Image
Brightens (darkens) desired rangedesired range
10
Piecewise-Linear Transform FunctionsBit-Plane Slicing
Gray (194) border:1 1 0 0 0 0 1 0 LSB1 1 0 0 0 0 1 0 LSB
MSB
11
Bit-Plane Slicing: Image Compressiong g p
The four highest-order bits are sufficient to reconstruct the original image in acceptable detail. 50% less storage.
12
Histogram Processingg gHistogram, kk nrh =)(
Normalized Histogram,MNnrp k
k =)(
Usefulness:Usefulness:
• Image EnhancementI C i• Image Compression
• Image Segmentation, etc.
Hi t f hi h t t i
13
Histogram of a high-contrast image has a high dynamic range.
Histogram Equalization - Ig q
10)( −≤≤= LrrTs 10 )( ≤≤= LrrTs
(a) T(r) is a monotonically increasing function in
10 −≤≤ Lr
and
(b) 10f1)(0 ≤≤≤≤ LLT(b) 10for 1)(0 −≤≤−≤≤ LrLrT
For inverse:For inverse:
(a) Is changed to
14
(a’) T(r) is strictly monotonically increasing function in 10 −≤≤ Lr
Histogram Equalization - IIg qIf pr (r) and T(r) are known, and T(r) is continuous and differentiable, then
dsdrrpsp rs )()( =
A common transformation function in image processing: ∫−==r
r dwwpLrTs0
)()1()(
)()1()()1()(
0
rpLwpdrdL
drrdT
drds
r
r
r −=⎥⎦
⎤⎢⎣
⎡−== ∫
Uniform probability density function
11
)()1(1)()()(
−=
−==
LrpLrp
dsdrrpsp rrs 10 −≤≤ Ls
Uniform probability density function
1)()1( −− LrpLds r
15
Histogram Equalization - IIIg qLet,
⎪
⎪⎨⎧ −≤≤
−=10for
)1(2
)( 2 LrL
rrpr
⎪⎩ otherwise 0)(
rr 2 Di t f∫∫ −
=−
=−==rr
r Lrwdw
LdwwpLrTs
0
2
0 112)()1()(
Discrete form:
∑−==k
jjrkk rpLrTs
0)()1()(
1
2)1(2)()(
−
⎥⎦⎤
⎢⎣⎡
−==
drds
Lr
dsdrrpsp rs
=j 0
∑ −=−
=k
jj Lkn
MNL
01,...1,0 )1(
)(
11
2)1(
)1(2
1)1(2
2
12
2 =−
=⎥⎦
⎤⎢⎣
⎡=
−
LrL
Lr
Lr
drd
Lr
=jMN 0
12)1(1)1( −−⎦⎣ −− LrLLdrL
Uniform distribution
16
Uniform distribution
Histogram Equalization - Exampleg q p
3 bit image (L=8) of size3-bit image (L=8) of size 64X64 (MN=4096) pixels.
08.3)(7)(7)(7)( 10
1
011 =+=== ∑
=
rprprprTs rrj
jr
We get:We get:
765.6 308.3623.6 133.1
51
40
→=→=→=→=
ssss
700.7 667.5786.6 555.4765.6308.3
73
62
51
→=→=→=→=→→
ssssss
Equalized histogram for r = 7: 11.04096
81122245=
++
17
4096
Histogram Matchingg gSpecified Histogram
⎧ 2Let,
⎪⎩
⎪⎨⎧ −≤≤
−=otherwise0
10for )1(
2)( 2 Lr
Lr
rpr⎪⎩ otherwise 0
Desired image whose intensity PDF: 0. otherwise ,10for )1(
3)( 3
2
−≤≤−
= LzL
zzpz )1(L
∫∫ −=
−=−==
rr
r Lrwdw
LdwwpLrTs
2
112)()1()(
LL 00 11
sL
zdwwL
dwwpLzGzz
z ===−= ∫∫ 2
32
2 )1()1(3)()1()(
LLz −− ∫∫ 20
20 )1()1(
[ ] [ ] 3/123/12
23/12 )1()1()1( rLrLsLz =⎥⎤
⎢⎡
==
18
[ ] [ ])1()1(
)1()1( rLL
LsLz −=⎥⎦
⎢⎣ −
−=−=
Histogram Matching: Example (1)g g p ( )
From previousFrom previous example:
31 == ss
766 53 1
54
32
10
======
ssssss
7 77 6
76
54
== ssss
19
Histogram Matching: Example (2)g g p ( )
∑=i
zpzG )(7)( ∑=
=j
jzi zpzG0
)(7)(
245.2)G(z 000.0)( 40 →=→=zG
7007)G(z1051)(695.5)G(z 000.0)(555.4)G(z 000.0)(
62
51
→=→=→=→=→=→=
zGzGzG
700.7)G(z 105.1)( 73 →=→=zG
Find the smallest value of z so that G(z ) is the closet to sFind the smallest value of zq so that G(zq) is the closet to sk.
790 19.04096790)( 3 ==zpz
20
Histogram Equalization vs Hist M t hi IHistogram Matching - I
Histogram Equalization:g
O i i l i d it hi t
Histogram-equalized image
21
Original image and its histogram image
Histogram Equalization vs Hist M t hi IIHistogram Matching - II
Histogram Matching:g g
Specified histogram:
Transformation:
22
Histogram StatisticsgMean (average intensity): ∑
−
=1
0)(
L
iii rprm
=0i
Intensity variance (second moment): ∑−
=
−=1
0
22 )()()(
L
iii rpmrrµ
=0i
Drill: Example 3.11
Without histogram:1 11 1 M NM N
[ ]∑∑∑∑−
=
−
=
−
=
−
=
−==1
0
1
0
221
0
1
0
),(1 and ),(1 M
x
N
y
M
x
N
y
myxfMN
yxfMN
m σ
Learn about local statistics.
23
Spatial Filteringp gConsists of: (1) A neighborhood.
(2) A d fi d ti th t i hb h d(2) A predefined operation on that neighborhood.
Filter response:Filter response:
)11()11()()00(...),1()0,1()1,1()1,1(),(
++++++−−+−−−−=
ffyxfwyxfwyxg
)1,1()1,1(...),()0,0( +++++ yxfwyxfw
For a mask of size m x n m = 2a+1 n = 2b+1:For a mask of size m x n, m 2a+1, n 2b+1:
∑ ∑ ++=a b
bttysxftswyxg ),(),(),(
−= −=as bt
24
Spatial Correlation & ConvolutionpCheck
CheckCheck
25
Spatial Correlation & Convolutionp2-D
26
Filter Mask
∑=
==+++=9
1992211 ...
k
Tkk zwzwzwzwR zw
Smoothing Filter (low pass) mask:
a b
∑ ∑
∑ ∑−= −=
++= a b
as bt
tsw
tysxftswyxg
),(
),(),(),(
∑ ∑−= −=as bt
),(
Normalization factor
27
Equal weight Weighted averageNormalization factor
Smoothing Effectg
Original image 3 X 3 mask
Noise is less pronounced.
5 X 5 mask
35 X 35 mask
C l t l bl d!
28
Completely blurred!
Median FilteringgFind the median in the neighborhood, then assign the center pixel value to that median.p
29
Sharpening Spatial Filtersp g pFirst-order derivative: )()1( xfxf
xf
−+=∂∂
Second-order derivative: )(2)1()1(2
2
xfxfxfxf
−−++=∂∂
First derivative:
1. Zero at constant area.2. Nonzero at onset.3. Nonzero along ramp.
Second derivative:
1. Zero at constant area.2. Nonzero at onset & end.3. Zero along constant
30
gslope ramp.
Laplacian Mask - IpSecond derivative is more useful in edge detection. x, y, and two
2
2
2
22
yf
xff
∂∂
+∂∂
=∇
diagonal directions
),(2),1(),1(
2
2
2
f
yxfyxfyxfxf
y
∂
−−++=∂∂
),1(),1(),(
),(2)1,()1,(
2
2
2
yxfyxfyxf
yxfyxfyxfyf
−++=∇∴
−−++=∂∂
),(4)1,()1,( ),(),(),(
yxfyxfyxfyfyfyf
−−+++
New image:
31
[ ]),(),(),( 2 yxfcyxfyxg ∇+=
Laplacian Mask - IIp
Original blurred image
Using Laplacian mask along x, y
Using Laplacian mask along x, y g , y
axesg , y
axes, and two diagonal
32
Unsharp Masking & Hi hb st Filt iHighboost Filtering
To sharpen an image1. Blur the original image.2. Subtract the blurred image from the original (result is mask).3 Add the mask to the original
g
3. Add the mask to the original.
)()()(),(),(),(
kfyxfyxfyxgmask −=
),(),(),( yxgkyxfyxg mask×+=
If k = 1, unsharp mask.If k 1, unsharp mask.If k > 1, highboost filtering.
33
top related