Gray-l l t f ti d ti l filt ilevel transformation and ...users.encs.concordia.ca/~weiping/DIP...
Transcript of Gray-l l t f ti d ti l filt ilevel transformation and ...users.encs.concordia.ca/~weiping/DIP...
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
G l l t f ti d ti l filt iGray-level transformation and spatial filtering
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
)],([),( yxfTyxg
Gray-level transformation:
)(
)],([),(
rTs
yxfTyxg
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Frequently UsedUsed TransformationsFrequently UsedUsed TransformationsFrequently UsedUsed TransformationsFrequently UsedUsed Transformations
1 Image negative1. Image negative
2. Logarithm:
2. Power law:
)1log( rcs
)( rcs
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Negative TransformationNegative TransformationNegative TransformationNegative Transformation
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Log Transformation in Frequency DomainLog Transformation in Frequency DomainLog Transformation in Frequency DomainLog Transformation in Frequency Domain
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
P L F ilP L F ilPower Law FamilyPower Law Family
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Correction of Response of CRT MonitorCorrection of Response of CRT MonitorCorrection of Response of CRT MonitorCorrection of Response of CRT Monitor
Response of CRT:
Gamma correction:
5.2rs
4.0rs
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Power Law TransformationPower Law TransformationPower Law TransformationPower Law Transformation
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Piecewise Linear TransformPiecewise Linear Transformecew se ea a s oecew se ea a s o
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Gray-Level SlicingGray-Level SlicingGray Level SlicingGray Level Slicing
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Gray Level SlicingGray Level SlicingGray-Level SlicingGray-Level Slicing
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Bit Plane RepresentationBit Plane Representationpp
Bit 7: ‘0’: gray-level 0 ~ 127 ; ‘1’: gray-level 128 ~ 255
Bit 6: ‘0’: 0 ~ 63, 128 ~ 191; ‘1’: 64 ~ 127, 192 ~ 255
:
Bit 0: ‘0’: levels 2, 4, … 254; ‘1’: 1, 3, 5, … 255
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial FilteringBit Plane RepresentationBit Plane Representation
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Bit plane reconstructed imageBit plane reconstructed imagep gp g
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering8 Bit-Plane Images8 Bit-Plane Images
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial FilteringHistogram of ImageHistogram of Image
Assume T(r) satisfies 2 conditions:
(a) T(r) is monotonically increasing function in [0, L-1].
(b) .10for1)(0 LrLrT
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Equalization AlgorithmEqualization Algorithmq gq gAssume :)(rpr p.d.f. of gray-level;
:)(rTs gray-level transformation. The p d f of transformed image:The p.d.f. of transformed image:
)(1||)()(sTrrs ds
drrpsp
From dpLrTsr
r0
)()1()( . r0
Then
)()1()()1()(0
rpLdpdrdL
drrdT
drds
r
r
r
,
11
|)(|)1(1)()()(
LrpLrp
dsdrrpsp
rrrs
Discrete case:
)1,...1,0()( LkMNnrp k
kr
© 2002 R. C. Gonzalez & R. E. Woods
k
jjj
k
jrkk n
MNLrpLrTs
00
1)()1()(
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Histogram EqualizationHistogram EqualizationHistogram EqualizationHistogram Equalization
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Example 3 5Example 3 5Example 3.5Example 3.5
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Similarly, s2=4.55, s3=5.67, s4=6.23, s5=6.65, s6=6.86, s7=7.00
Next, the new intensity levels are rounded to the nearest integers:
Similarly, s2=4.55, s3=5.67, s4=6.23, s5=6.65, s6=6.86, s7=7.00
Next, the new intensity levels are rounded to the nearest integers:
s0=1, s1=3, s2=5, s3=6, s4=6, s5=6, s6=7, s7=7 s0=1, s1=3, s2=5, s3=6, s4=6, s5=6, s6=7, s7=7
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
T f ( d f f l l)T f ( d f f l l)Transforms (c.d.f. of gray-level)Transforms (c.d.f. of gray-level)
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Gray-Level MappingGray-Level Mapping
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Image & HistogramImage & HistogramImage & HistogramImage & Histogram
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Histogram matchingHistogram matchingHistogram matchingHistogram matching
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Histogram MatchingHistogram MatchingHistogram MatchingHistogram MatchingGiven p.d.f. )(rpr , dpLrTs
r
r0
)()1()(
For desired p.d.f. )(zp z , let
dttpLzGsz
z0
)()1()(
Then )]([][ 11 rTGsGz . Discrete case:
1. 1)()1()(
00
nMNLrpLrTs
k
jjj
k
jrkk
)1,...1,0( Lk
2. For a value of q , compute )()1()(0
i
q
izq zpLzG
such that )1,...1,0()( LkszG kq
where )( iz zp is the i-th value of the specified histogram.
3 ][)]([ 11 sGrTGz )110( Lq
© 2002 R. C. Gonzalez & R. E. Woods
3. ][)]([ kkq sGrTGz , )1,...1,0( Lq
That is qsG
krT
k zsr kk ][)( 1
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Example 3 8Example 3 8Example 3.8Example 3.8
00.0)(7)(0
00
j
jz zpzG
00.0)()(7)(7)( 10
1
01
zpzpzpzG zzjj
z
SimilarlySimilarly,
45.2)(,05.1)(,00.0)( 432 zGzGzG
00.7)(,95.5)(,55.4)( 765 zGzGzG )(,)(,)( 765
Rounding to integer,
1)(0)(0)(0)( zGzGzGzG 1)(,0)(,0)(,0)( 3210 zGzGzGzG
7)(,6)(,5)(,2)( 7654 zGzGzGzG
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Histogram EqualizationHistogram EqualizationHistogram EqualizationHistogram Equalization
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Local histogram equalizationLocal histogram equalizationLocal histogram equalizationLocal histogram equalization
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Enhancement using Histogram StatisticsEnhancement using Histogram StatisticsEnhancement using Histogram StatisticsEnhancement using Histogram StatisticsThe n-th order moment ,
)()()(1
i
Ln
in rpmrr
, )()(1
i
L
i rprrEm
0i
,0i
m and 22 )( rr can be used for local enhancement.
It is common practice to estimate mean and variance: 1 11 M N 1 11 M N
1
0
1
0
),(1 M
x
N
y
yxfMN
m ,
1
0
1
0
22 ]),([1 M
x
N
yr myxf
MN
Given a small area yxS centered at (x,y),Given a small area yx , centered at (x,y),
1
0
221
0
)()(,)(,,,,,
L
iiSSiS
L
iiSiS rpmrrprm
yxyxyxyxyx
An enhancement algorithm:
otherwiseyxf
DkDkMkmyxfEyxg GSGGS yxyx
)(,),(
),( 210 ,,
© 2002 R. C. Gonzalez & R. E. Woods
otherwiseyxf ),(
:GM global mean; :GD global standard deviation.
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Example using local histogram statisticsExample using local histogram statistics
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Spatial filteringSpatial filtering
a b
tysxftswyxg ),(),(),( as bt
,12 am .12 bn
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
1 D Correlation and convolution1-D Correlation and convolution
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
2 D Correlation and convolution2-D Correlation and convolution
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
3x3 filter mask
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
3x3 smoothing filter
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Image smoothing using smoothing filters of different sizes
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Image smoothing and thresholding
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Salt-and pepper noise reduction using 3x3 filter masks
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Sharpening spatial filtersSharpening spatial filters1st order derivative:
2nd order derivative:
1st order derivative:Produces thicker edges;Generally has a stronger response to a gray-level step;Generally has a stronger response to a gray level step;
2nd order derivative:Stronger response to fine details thin lines isolated points;Stronger response to fine details, thin lines, isolated points;Yields a double response at step edges
© 2002 R. C. Gonzalez & R. E. Woods
For most applications, 2nd order derivative is better.
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Sharpening spatial filtersSharpening spatial filters
Laplacian operator,
ff 22 y
fxfyxf
2
2
2
22 ),(
where
),(2),1(),1(2
2
yxfyxfyxfxf
2
),(2)1,()1,(2
2
yxfyxfyxfyf
),(2)1,(
)1,(),1(),1(),(2
yxfyxf
yxfyxfyxfyxf
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
1st and 2nd derivatives of 1 D image1st and 2nd derivatives of 1-D image
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Filter masks to implement the LaplacianFilter masks to implement the Laplacian
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Image sharpening using LaplacianImage sharpening using Laplacian
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Unsharpening and highboost filteringUnsharpening and highboost filtering
),(),(),( yxfyxfyxg m a sk )(*)()( kf ),(*),(),( yxgkyxfyxg ma sk
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Image sharpening using 1st derivative Gradient
Gradient,
Image sharpening using 1st derivative - Gradient
yfxf
y
x
GG
yxf ),(
Or
21
22),( yx GGyxf ,
||||),( yx GGyxf
If using 3x3 mask,g ,
|)2()2(|
|)2()2(|),(
741963
321987
zzzzzz
zzzzzzyxf
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
i i l i i diDigital approximation to gradient
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Edge enhancement using gradientEdge enhancement using gradient
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Image enhancement using derivativesImage enhancement using derivatives
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Spatial domain image enhancement mixed methodSpatial domain image enhancement – mixed method
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
F tFuzzy set
})(,{ ZzzzA A
) }1.0,2 9(. . . ,) ,8.0,2 2() ,9.0,2 1() ,1,2 0(. . . ,) ,1,2() ,1,1{ (A
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Fuzzy set operationEmpty set: A fuzzy set is empty iff 0)( zA for all .Zz
Fuzzy set operation
Equality: A=B iff )()( zz BA for all .Zz Complement: A is complement of A if )(1)( zz AA for all .Zz Subset: A is a subset of B iff )()( zz BA for all .Zz U iUnion: BAU has )](),(max[)( zzz BAU for all .Zz Intersection:
© 2002 R. C. Gonzalez & R. E. Woods
Intersection: BAI has )](),(min[)( zzz BAI for all .Zz
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Set operation exampleSet operation example
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Commonly used membership functionsCommonly used membership functions
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Fuzzy set application in color sensation
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
A li ti f b hi f tiApplication of membership function
R1: IF the color is green, THEN the fruit is verdant. OROR
R2: IF the color is yellow, THEN the fruit is half-mature.OR
R3: IF the color is red THEN the fruit is mature
© 2002 R. C. Gonzalez & R. E. Woods
R3: IF the color is red, THEN the fruit is mature.
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Fuzzy set operation
)}()(i {)(
© 2002 R. C. Gonzalez & R. E. Woods
)}(),(min{),(3 vzvz matred
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Fuzzy set operation
)},(),(min{)( 0303 vzzvQ red
)},(),(min{)()},(),(min{)(
0303
0302
vzzvQvzzvQ
green
yellow
© 2002 R. C. Gonzalez & R. E. Woods
)},(),({)( 0303Q green
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Membership functions for color representationMembership functions for color representation
K
vQv )(
© 2002 R. C. Gonzalez & R. E. Woods
321 QORQORQQ . Center of gravity:
K
v
v
vQ
vQvv
1
1
)(
)(
0
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
i l i i h iFuzzy system implementation with more inputs
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
l b d hFuzzy, rule-based contrast enhancement
If a pixel is dark, then make it darker.If i l i h k iIf a pixel is gray, then make it gray.If a pixel is bright, then make it brighter.
)()()( 0000
vzvzvzv bbrightggreyddark
© 2002 R. C. Gonzalez & R. E. Woods
)()()( 0000 zzz
vbrightgreydark
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
C h i hiContrast enhancement using histogram equalization and fuzzy system
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
HistogramsHistograms
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
S i l fil i i fSpatial filtering using fuzzy sets
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Boundary detection using fuzzy rulesBoundary detection using fuzzy rules
© 2002 R. C. Gonzalez & R. E. Woods
Chapter 3 Intensity Transformations & Spatial FilteringChapter 3 Intensity Transformations & Spatial Filtering
Fuzzy spatial filteringFuzzy spatial filtering
© 2002 R. C. Gonzalez & R. E. Woods