You are on page 1of 29

lmaae rocesslna wlLh CpenCv

M2010 Semlnar
!"#$%&%'()%*%(
+%,-.//.(0%-"*1(
CuLllne
lnLroducuon
olnL CperaLor
PlsLoaram
1hreshold
Local CperaLor
Convoluuon
SmooLhlna
CradlenL CperaLors
CuLllne olnL CperaLors
PlsLoaram
lnLroducuon
normallzauon and Lquallzauon
PlsLoaram MaLchlna
PlsLoaram ln CpenCv
1hreshold
lnLroducuon
1vpoloav and Lxample
1hreshold ln CpenCv
CuLllne Local CperaLor
Convoluuon
lnLroducuon and example
SmooLhlna
Averaae
Causslan
Medlan
SmooLhlna ln CpenCv
lmaae 1hreshold
lL ls Lhe baslc operauon LhaL can be done on an
lmaae.
CaLeaorlcallv re[ecL Lhose plxels below or above
some value whlle keeplna Lhe oLhers.
lmaae 1hreshold
If ( I(i,j) > T )!
!O(i,j) = M!
else!
!O(i,j) = 0!
If ( I(i,j) > T )!
!O(i,j) = 0!
else!
!O(i,j) = M!
lmaae 1hreshold
If ( I(i,j) > T )!
!O(i,j) = 0!
else!
!O(i,j) = I(i,j)!
If ( I(i,j) > T )!
!O(i,j) = I(i,j)!
else!
!O(i,j) = 0!
lmaae 1hreshold
If ( I(i,j) > T )!
!O(i,j) = T!
else!
!O(i,j) = I(i,j)!
WhaL ls 1hreshold?
Pow we can locallze a !"#$%&'("#") orlenLauon equlpped wlLh Lwo LLu?
Courtesy of Iacopo Masi
WhaL ls 1hreshold?
Slmplv 1hresholdlna!
Courtesy of Iacopo Masi
lmaae 1hreshold ln CpenCv
Lhreshold_Lvpe:
Cv_1P8LSP_8lnA8?, Cv_1P8LSP_8lnA8?_lnv
Cv_1P8LSP_18unC
Cv_1P8LSP_1CZL8C, Cv_1P8LSP_1CZL8C_lnv
Local CperaLors
Local operaLors use a small nelahborhood of a
plxel ln Lhe lnpuL lmaae Lo aeL Lhe new
lnLenslLv value for Lhe correspondlna plxel ln
Lhe ouLpuL lmaae.
rocesslna wlLh local operaLors ls Lvplcallv
used for Lwo dlerenL purposes:
SmooLhlna
CradlenL CperaLors
*!"")+$,-.alms Lo suppress nolse
or oLher undeslred ucLuauons ln Lhe lmaae.
unforLunaLelv, smooLhlna also blurs all sharp lnLenslLv
Lransluons
lxels correspondlna Lo sharp lnLenslLv Lransluons are Lvplcallv referred Lo as
edaes and vlolaLe Lhe conunulLv hvpoLhesls
Ldaes mav bear lmporLanL lnformauon abouL Lhe
lmaae, prlmarllv abouL conLours of ob[ecLs
Local CperaLors
/(01$&,)."2&(0)"(3.are based on local
derlvauves of Lhe lmaae funcuon.
uerlvauves are blaaer aL locauons of Lhe lmaae where Lhe
lmaae funcuon underaoes rapld chanaes. 1he alm of aradlenL
operaLors ls Lo hlahllahL such locauons ln Lhe lmaae.
unforLunaLelv, lf a aradlenL operaLor ls applled Lo an lmaae
Lhe nolse level lncreases slmulLaneouslv.
SmooLhlna and aradlenL operaLors have conlcuna alms.
Local CperaLors
Convoluuon
ln llnear operaLors, value 2
'
3%456 of Lhe ouLpuL lmaae ls
compuLed Lhrouah a welahLed sum of values of plxels
of Lhe lnpuL lmaae 2
%
3%456 ln a nelahborhood(of(plxel 3%456(
8elna 738486 Lhe welahL coemclenLs
Rectangular neighborhoods are typically used with an odd
number of rows and columns(
Convoluuon
I
i
( i-1 , j-1 )

I
i
( i-1 , j )

I
i
( i-1 , j+1 )

I
i
( i , j-1 )

I
i
( i , j )

I
i
( i , j+1 )

I
i
( i+1 , j-1 )

I
i
( i+1 , j )

I
i
( i+1 , j+1 )

h(-1,-1) h(-1,0) h(-1,1)
h(0,-1) h(0,0) h(0,1)
h(1,-1) h(1,0) h(1,1)
Mask coefficient showing
coordinate arrangement
Image Origin
Pixels of image
Section under mask
Mask
Convoluuon Lxample
Convoluuon Lxample (conL)
Convoluuon Lxample (conL)
Convoluuon ln CpenCv
Source lmaae
uesunauon lmaae
1he kernel maLrlx
1he anchor polnL lndlcaLes Lhe locauon of Lhe cenLer of Lhe
kernel. 1he defaulL value ls cvolnL(-1,-1).
kernel denluon requlres:
1he dlmenslon of Lhe kernel (8ows,Cols)
1he kernel maLrlx
1he denluon of Lhe maLrlx header and daLa for Lvpe 4560).
Convoluuon ln CpenCv
SmooLhlna
Averaae SmooLhlna
Causslan SmooLhlna
Medlan SmooLhlna
Averaae SmooLhlna
Cne of Lhe purposes of smooLhlna ls Lo suppress
lmaae nolse or undeslred lmaae ucLuauons bv
exploluna redundancv of lmaae daLa
ln lLs slmplesL form, compuLauon of Lhe new value of
Lhe smooLhed lmaae 2
'
3%456(ls based on 05&(0-$,-.of
lnLenslLv values ln some nelahborhood of Lhe plxel
3%456 ln Lhe lnpuL lmaae
1 1 1
1 1 1
1 1 1
1/9
1 2 1
2 4 2
1 2 1
1/16
Causslan SmooLhlna
value of Lhe cenLral elemenL of mask kernel should
be hlaher Lhan values of oLher elemenLs:
1hls ls because value of Lhe cenLral lmaae plxel has Lhe
hlahesL relevance for compuLauon of Lhe ouLpuL value.
1he furLher awav Lhe nelahbors, Lhe smaller Lhe
welahL.
0.003 0.013 0.022 0.013 0.003
0.013 0.059 0.098 0.059 0.013
0.021 0.098 0.170 0.098 0.021
0.013 0.059 0.098 0.059 0.013
0.003 0.013 0.022 0.013 0.003
Medlan SmooLhlna
Clven a seL of ordered sequence of scalar values Lhe
medlan value ls Lhe cenLral value
ln Lhe case of lnLenslLv plxel values Lhe medlan ls
compuLed as follows:
Crder arav values ln ascendlna order
SelecL Lhe cenLral elemenL of Lhe llsL
Medlan SmooLhlna
uoes noL blur edaes much
noL aecLed bv lndlvldual nolse splkes and lmpulslve
nolse
lmpulslve and splke nolse ls removed and lL doesn'L alLer Lhe lnLenslLv
value of nelahborlna plxels
ls a closed operaLor
Clven a seL 9 Lhe medlan of 9 ls an elemenL of 9 (Lhls ls noL Lrue for Lhe
mean operaLor)
SmooLhlna
Noisy Input Average Gaussian Median
SmooLhlna ln CpenCv
smooLhLvpe:
Cv_8Lu8
Cv_CAuSSlAn
Cv_MLulAn
SmooLhlna ln CpenCv
lor Lhe Causslan and Averaae blur, Lhe rsL Lwo
parameLers alve Lhe wldLh and helahL of Lhe lLer
wlndow,
1he (opuonal) Lhlrd parameLer lndlcaLes Lhe slama
value onlv for Lhe Causslan kernel.
lor medlan onlv param1 ls necessarv

You might also like