Sunteți pe pagina 1din 29

lmage rocesslng wlLh CpenCv

M2010 Semlnar
!"#$%&%'()%*%(
+%,-.//.(0%-"*1(
CuLllne
lnLroducuon
olnL CperaLor
PlsLogram
1hreshold
Local CperaLor
Convoluuon
SmooLhlng
CradlenL CperaLors
CuLllne olnL CperaLors
PlsLogram
lnLroducuon
normallzauon and Lquallzauon
PlsLogram MaLchlng
PlsLogram ln CpenCv
1hreshold
lnLroducuon
1ypology and Lxample
1hreshold ln CpenCv
CuLllne Local CperaLor
Convoluuon
lnLroducuon and example
SmooLhlng
Average
Causslan
Medlan
SmooLhlng ln CpenCv
CompuLer vlslon
WhaL Lhe compuLer -..-"
ls [usL a grld of numbers. Any
glven number wlLhln LhaL grld
has a raLher large nolse
componenL and so by lLself
glves us llule lnformauon, buL
Lhls grld of numbers ls all
Lhe compuLer -..-".
1he human braln dlvldes Lhe vlslon slgnal lnLo many channels LhaL
sLream dlerenL klnds of lnformauon lnLo your braln. ?our braln has an
auenuon sysLem LhaL ldenues, ln a Lask-dependenL way, lmporLanL
parLs of an lmage Lo examlne whlle suppresslng examlnauon of oLher
areas.
1he alm of lmage processlng ls Lo help Lhe compuLer Lo
undersLand Lhe conLenL of an lmage (feaLures exLracuon such
as: colors, shape of ob[ecLs, color of ob[ecLs).
1hls can be achleved Lhrough Lhe developmenL of algorlLhms
for lmage processlng.
LxLracL whaL happens by processlng muluple lmages of Lhe
same sequence or dlerenL sequences (lnLeracuon beLween
ob[ecLs, such as occluslon).
1he comblnauon of baslc Lechnlques has led Lo Lhe
developmenL of very powerful feaLures for ob[ecL recognluon
(e.g. Sll1 on Mars)
CompuLer vlslon
PlsLogram
1hey are used Lo obLaln a sLausucal plcLure of Lhe
underlylng dlsLrlbuuon of daLa.
ln Lhe course of analyzlng lmages, ob[ecLs, and vldeo
lnformauon, we frequenLly wanL Lo represenL whaL
we are looklng aL as a hlsLogram2(
PlsLograms are slmply collecLed counLs of Lhe
underlylng daLa organlzed lnLo a seL of predened
blns.
PlsLogram
lor hlsLogram denluon we can assume an lmage wlLh
[usL one lnLenslLy channel.
PlsLogram:
Where $
3
ls Lhe 3Lh gray level and *
3
ls Lhe number of
plxels ln Lhe lmage havlng gray level $
3(
Lach gray level ls a bln, more blns := more deLalls :=
more compuLauonal complexlLy. (
PlsLogram
Gray Levels: {0,1, , 255}
Number of Bins: 32
Number of intensity levels for each bin: 256 / 32 = 8
6 12 16
200px
620px
370px
PlsLogram normallzauon
normallzed PlsLogram (why you have Lo do lL?)
lL ls oen deslrable Lo work wlLh Lhe hlsLogram ln normallzed
form, so LhaL lndlvldual blns wlll Lhen represenL Lhe fracuon of
Lhe LoLal number of evenLs asslgned Lo Lhe enure hlsLogram.
normallzed hlsLogram values musL be represenLed by oaL or
double. CLherwlse Lhere may be loss of lnformauon due Lo
Lruncauon.
PlsLogram Lquallzauon
Cameras and lmage sensors musL usually deal noL
only wlLh Lhe conLrasL ln a scene buL also wlLh Lhe
lmage sensors' exposure Lo Lhe resulung llghL ln
LhaL scene.
Aer Lhe plcLure has been Laken, Lhere's noLhlng
we can do abouL whaL Lhe sensor recorded,
however, we can sull Lake whaL's Lhere and Lry Lo
expand Lhe dynamlc range of Lhe lmage.
PlsLogram Lquallzauon
PlsLogram Lquallzauon (why you have Lo do lL?)
1he lmage ls poor because Lhere's noL much varlauon of Lhe
range of values. 1hls ls evldenL from Lhe hlsLogram of lLs
lnLenslLy values on Lhe rlghL
PlsLogram equallzauon ls a meLhod for sLreLchlng Lhls range
ouL.
PlsLogram Lquallzauon
PlsLogram equallzauon lnvolves mapplng one dlsLrlbuuon (Lhe
glven hlsLogram of lnLenslLy values) Lo anoLher dlsLrlbuuon (a
wlder and, ldeally, unlform dlsLrlbuuon of lnLenslLy values).
Spread ouL Lhe 4-values of Lhe orlglnal dlsLrlbuuon as evenly
as posslble ln Lhe new dlsLrlbuuon.
uenluon of cumulauve:
PlsLogram Lquallzauon
It is possible to use the cumulative distribution function to remap the
original distribution as an equally spread distribution simply by looking up
each y-value in the original distribution and seeing where it should go in
the equalized distribution.
PlsLogram: 8C8 vs PSv
8C8 ls noL a good color space.
uslng PSv we can remove v (Lhe value of lnLenslLy) and Lhen
we can handle wlLh large varlauons of lllumlnauon.
8C8 PSv
P
S
v
PS
PlsLogram MaLchlng
PlsLograms are usually used Lo nd slmllarlLy
beLween ob[ecLs LhaL conLaln (or noL) Lhe same
color or sLausucs.
PlsLogram MaLchlng
erformlng a comparlson beLween blns of
hlsLograms of dlerenL lmages.
PlsLograms wlll have Lhe same number of blns.
1here are several meLhods Lo perform
hlsLogram maLchlng.
PlsLogram MaLchlng
Correlauon:
Chl-Square:
A high score represents a better match than a low score:
A perfect match is 1;
A maximal mismatch is 1;
A value of 0 indicates no correlation (random association).
A low score represents a better match than a high score.
A perfect match is 0
A total mismatch is unbounded (depending on the size of the histogram).
PlsLogram MaLchlng PlsLogram MaLchlng
lnLersecuon:
8hauacharyya:
High scores indicate good matches and low scores indicate bad matches.
If both histograms are normalized to 1, then:
A perfect match is 1
A total mismatch is 0
Low scores indicate good matches and high scores indicate bad matches.
A perfect match is 0
A total mismatch is a 1.
PlsLogram ln CpenCv
CpenCv has a daLa Lype for represenung hlsLograms
ln one or many dlmenslons.
lL ls equlpped wlLh a varleLy of useful funcuons Lo
easlly perform common operauons on hlsLograms.
1he lnLernal daLa of Lhe hlsLogram ls sLored lnslde of
Lhe CvMaLnu sLrucLure
PlsLogram ln CpenCv
For a uniform histogram, ranges is an array of floating-point
value pairs, where the number of value pairs is equal to the
number of dimensions.
For a non-uniform histogram, the pairs used by the uniform
histogram are replaced by arrays containing the values by which
the non-uniform bins are separated. If there are N bins, then
there will be N + 1 entries in each of these subarrays.
PlsLogram ln CpenCv
1he Lype can be elLher Cv_PlS1_A88A?, whlch ls used
for muludlmenslonal hlsLograms Lo be sLored uslng
Lhe dense muludlmenslonal maLrlx sLrucLure (l.e.,
CvMaLnu),
or Cv_PlS1_ SA8SL lf Lhe daLa ls Lo be sLored uslng
Lhe sparse maLrlx represenLauon (CvSparseMaL).
PlsLogram ln CpenCv
For the i-th channel there are 30 bins in a range from 0 to 180,
therefore 6 levels of intensity for each bin.
For the j-th channel there are 32 bins in a range from 0 to 255,
therefore 8 levels of intensity for each bin.
Accesslng PlsLogram ln CpenCv
Lach of Lhe funcuons on Lhe le reLurns a oaung-polnL number for
Lhe value ln Lhe approprlaLe bln.
lL ls also posslble Lo seL (or geL) hlsLogram bln values wlLh Lhe
funcuons LhaL reLurn a polnLer Lo a bln (*'5(5'("(#%*6-(7"8,.9:
PlsLogram MaLchlng ln CpenCv
meLhod:
Cv_CCM_CC88LL
Cv_CCM_CPlSC8
Cv_CCM_ln1L8SLC1
Cv_CCM_8PA11ACPA8??A
PlsLogram Manlpulauon ln CpenCv
PlsLogram normallzauon:
PlsLogram 1hresholdlng:
The argument factor is the cutoff for the threshold.
The result of thresholding a histogram is that all bins whose value
is below the threshold factor are set to 0.
PlsLogram Manlpulauon ln CpenCv
PlsLogram Lquallzauon:
The source and destination must be a single-channel, 8-
bit images of the same size.
For color images you will have to separate the channels
and process them one by one.
Mask ln CpenCv
Some funcuon ln CpenCv
can Lake as lnpuL a blnary
mask of Lhe same slze of Lhe
source.
1hls can be used Lo process
or ln parucular calculaLe Lhe
hlsLogram for only one area
of Lhe lmage.
cv8ecLangle(.):
Cne of Lhe recLangle's veruces and Lhe opposlLe recLangle verLex
Llne color (8C8) or brlghLness (grayscale lmage)
1hlckness of llnes LhaL make up Lhe recLangle. negauve values cause
Lhe funcuon Lo draw a lled recLangle (Cv_llLLLu)
1ype of Lhe llne
Mask ln CpenCv

S-ar putea să vă placă și