Intensity Transformations, Spatial Fil i Hi P iFiltering...
Transcript of Intensity Transformations, Spatial Fil i Hi P iFiltering...
![Page 1: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/1.jpg)
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
![Page 2: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/2.jpg)
Intensity Transfer Functions y
Contrast stretching function. Thresholding function.
r: intensity variable of input image.
2
s: intensity variable of output image.
![Page 3: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/3.jpg)
Basic Intensity Transfer Functions y
• Linear• Logarithmicoga c• Power‐law
3
![Page 4: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/4.jpg)
Negative Transformation gIntensity level: [0, L - 1]
rLs −−= 1
4Original Image Negative Image
![Page 5: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/5.jpg)
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
![Page 6: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/6.jpg)
Power-Law (Gamma) Transformation ( )γcrs =
6
![Page 7: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/7.jpg)
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.
![Page 8: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/8.jpg)
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
![Page 9: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/9.jpg)
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
![Page 10: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/10.jpg)
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
![Page 11: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/11.jpg)
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
![Page 12: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/12.jpg)
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
![Page 13: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/13.jpg)
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.
![Page 14: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/14.jpg)
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
![Page 15: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/15.jpg)
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
![Page 16: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/16.jpg)
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
![Page 17: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/17.jpg)
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
![Page 18: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/18.jpg)
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 −=⎥⎦
⎢⎣ −
−=−=
![Page 19: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/19.jpg)
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
![Page 20: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/20.jpg)
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
![Page 21: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/21.jpg)
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
![Page 22: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/22.jpg)
Histogram Equalization vs Hist M t hi IIHistogram Matching - II
Histogram Matching:g g
Specified histogram:
Transformation:
22
![Page 23: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/23.jpg)
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
![Page 24: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/24.jpg)
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
![Page 25: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/25.jpg)
Spatial Correlation & ConvolutionpCheck
CheckCheck
25
![Page 26: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/26.jpg)
Spatial Correlation & Convolutionp2-D
26
![Page 27: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/27.jpg)
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
![Page 28: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/28.jpg)
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!
![Page 29: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/29.jpg)
Median FilteringgFind the median in the neighborhood, then assign the center pixel value to that median.p
29
![Page 30: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/30.jpg)
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.
![Page 31: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/31.jpg)
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 ∇+=
![Page 32: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/32.jpg)
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
![Page 33: Intensity Transformations, Spatial Fil i Hi P iFiltering ...faculty.ksu.edu.sa/sites/default/files/topic2_ch3.pdf · Intensity Transformations, Spatial Fil i Hi P iFiltering, Histogram](https://reader033.fdocuments.in/reader033/viewer/2022052101/603b213b232ced34897eae20/html5/thumbnails/33.jpg)
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