INF 4300 Dgtal Image Aaly REEIION Ae Solberg 805 INF 4300 Repetto -Eroo of a bary mage Smplfed otato o compute the eroo of pel,y mage f wth the tructurg elemet S: place the tructurg elemet uch that t orgo at,y Compute g, y 0 f S ft f otherwe Eroo of the mage f wth tructurg elemet S deoted ε f S = f ө S Eroo of a et A wth the tucturg elemet B defed a the poto of all pel A uch that B cluded A whe orgo of B at A B B A gve 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 eroded by 0 0 0 0 gve 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 INF 4300
Dlato of a bary mage lace S uch that orgo le pel,y ad ue the rule f S ht f g, y 0 otherwe he mage f dlated by the tructurg elemet S deoted: f S Dlato of a et A wth a tructurg elemet B defed a the poto of all pel uch that B overlap wth at leat oe pel A whe the org placed at A B B A Ø 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Dlated by gve 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 INF 4300 3 Opeg Eroo of a mage remove all tructure that the tructurg elemet ca ot ft de, ad hrk all other tructure Dlatg the reult of the eroo wth the ame tructurg elemet, the tructure that urvved the eroo were hruke, ot deleted wll be retored h called morphologcal opeg: f S f θ S S he ame tell that the operato ca create a opeg betwee two tructure that are coected oly a th brdge, wthout hrkg the tructure a eroo would do INF 4300 4
Clog A dlato of a obect grow the obect ad ca fll gap If we erode the reult wth the rotated tructurg elemet, the obect wll keep ther tructure ad form, but mall hole flled by dlato wll ot appear Obect merged by the dlato wll ot be eparated aga Clog defed a f S f Ŝ θ Sˆ h operato ca cloe gap betwee two tructure wthout growg the ze of the tructure lke dlato would INF 4300 5 Gray level morphology We apply a mplfed defto of morphologcal operato o gray level mage Grey-level eroo, dlato, opeg, clog Image f,y Structurg elemet b,y Noflat or flat Aume ymmetrc, flat tructurg elemet, orgo at ceter th uffcet for ormal ue Eroo ad dlato the correpod to local mmum ad mamum over the area defed by the tructurg elemet INF 4300 6
Iterpretato of grey-level opeg ad clog Itety value are terpreted a heght curve over the,y-plae Opeg of f by b: uh the tructurg elemet up from below toward the curve f he value aged the hghet level b ca reach mooth brght value dow Clog: uh the tructurg elemet dow from above toward the curve f mooth dark value upward INF 4300 7 op-hat traformato urpoe: detect or remove tructure of a certa ze op-hat: detect lght obect o a dark backgroud alo called whte top-hat Bottom-hat: detect dark obect o a brght backgroud alo called black top-hat op-hat: Bottom-hat: f f b f b f Very ueful for correctg ueve llumato/obect o a varyg backgroud INF 4300 8
Eample top-hat Orgal, u-eve backgroud Global threholdg ug Otu method Obect the lower rght corer dappear Mclafcato of backgroud upper left corer Opeg wth a 4040 tructurg elemet remove obect ad gve a etmate of the backgroud op-hat traform orgal opeg op-hat, threholded wth global threhold INF 4300 9 Learg goal - morphology Udertad detal bary morphologcal operato ad elected applcato: Bac operator eroo, dlato, opeg, clog Udertad the mathematcal defto, perform them by had o ew obect Applcato of morphology: edge detecto, coected compoet, cove hull etc Verfy the eample the book Grey-level morphology: Udertad how grey-level eroo ad dlato ad opeg ad clog work Udertad the effect thee operato have o mage Udertad top-hat, bottom-hat ad what they are ued for INF 4300 0
wo correlated feature feature alg o a e INF 4300 Mea vector ad covarace matrce N dmeo If f a -dmeoal feature vector, we ca formulate t mea vector ad covarace matr a: wth feature, the mea vector wll be of ze ad or ze he matr wll be ymmetrc a kl = lk INF 4300 E E E E f f f f
Baye rule for a clafcato problem Suppoe we have J, =,J clae the cla label for a pel, ad the oberved gray level or feature vector We ca ue Baye rule to fd a epreo for the cla wth the hghet probablty: p p pror probablty poteror probablty lkelhood ormalzg factor For threholdg, the pror probablty for backgroud or foregroud If we do't have pecal kowledge that oe of the clae occur more frequet tha other clae, we et them equal for all clae =/J, =,,,J Small p mea a probablty dtrbuto Captal mea a probablty calar value betwee 0 ad INF 4300 3 robablty of error If we have clae, we make a error ether f we decde f the true cla f we decde f the true cla If > we have more belef that belog to, ad we decde he probablty of error the: f we decde error f we decde INF 4300 4
Back to clafcato error for threholdg - Backgroud - Foregroud error error, d error p d I th rego, foregroud pel are mclafed a backgroud I th rego, backgroud pel are mclafed a foregroud INF 4300 5 Mmzg the error error error, d error p d Whe we derved the optmal threhold, we howed that the mmum error wa acheved for placg the threhold or deco boudary a we wll call t ow at the pot where = h tll vald INF 4300 6
Baye deco rule I the cla cae, our goal of mmzg the error mple a deco rule: Decde ω f ω >ω ; otherwe ω For J clae, the rule aaloguly eted to chooe the cla wth mamum a poteror probablty he deco boudary the border betwee clae ad, mply where ω =ω Eactly where the threhold wa et mmum error threholdg! INF 3300 7 Dcrmat fucto he deco rule Decde f, for all ca be wrtte a ag to f g g he clafer compute J dcrmat fucto g ad elect the cla correpodg to the larget value of the dcrmat fucto Sce clafcato cot of choog the cla that ha the larget value, a cag of the dcrmat fucto g by fg wll ot effect the deco f f a mootocally creag fucto h ca lead to mplfcato a we wll oo ee INF 4300 8
Equvalet dcrmat fucto he followg choce of dcrmat fucto gve equvalet deco: he effect of the deco rule to dvde the feature pace to c deco rego R,R c If g >g for all, the rego R he rego are eparated by deco boudare, urface feature pace where the dcrmat fucto for two clae are equal INF 4300 9 p g p g p p g INF 4300 0 he codtoal dety p Ay probablty dety fucto ca be ued to model p A commo model the multvarate Gaua dety he multvarate Gaua dety: If we have d feature, a vector of legth d ad ad a dd matr deped o cla the determat of the matr, ad - the vere t p / / ep S S 3 Symmetrc dd matr the varace of feature the covarace betwee feature ad feature Symmetrc becaue =
Ipectg p p ep d / / t Scalar vector trapoed vector trapoed Scalar probablty matr Ivere of covarace matr INF 4300 he mea vector for each cla he mea vector for cla defed a the epected value of : E E E E d d cla feature umber d wth d feature, the mea vector wll be of ze d If we have M trag ample that we kow belog to cla, we ca etmate the mea vector a: ˆ M M m m, where the um over all trag ample belogg to cla INF 4300
he covarace matr for each cla he covarace for cla defed a the epected value of -- t : wth d feature, the covarace matr wll be of ze dd If we have M trag ample that we kow belog to cla, we ca etmate the covarace matr he etmate of a radom varable f deoted Each term computed a: INF 4300 3 d d d d d dd d d d d trag ample belogg to cla over all where the um ˆ ˆ ˆ t m M m m M for cla ad for the covarace betwee feature ˆ ˆ,,,, t m M m m M fˆ More o the covarace matr he covarace matr wll alway be ymmetrc ad potve emdefte If all compoet of have o-zero varace, wll be potve defte the covarace betwee feature ad If feature ad are ucorrelated, = 0 I the geeral cae, wll have dd+/ dfferet value INF 4300 4
A D Gaua model arameter ad defe a dety a a bump he curve o the plot are cotour of equal probablty, ut a the cotour o a map he matr th cae ha three dfferet elemet, varace each of the ae, ad covarace betwee the ae S the varace for feature = the covarace betwee feature ad the varace for feature INF 4300 5 he covarace matr ad ellpe I D, the Gaua model ca be thought of a appromatg the clae D feature pace wth ellpe he mea vector =[, ] defe the the ceter pot of the ellpe, the covarace betwee the feature defe the oretato of the ellpe ad defe the wdth of the ellpe S he ellpe defe pot where the probablty dety equal Equal the ee that the dtace to the mea a computed by the Mahalaob dtace equal he Mahalaob dtace betwee a pot ad the cla ceter : r he ma ae of the ellpe determed by the egevector of he egevalue of gve ther legth INF 4300 6
Eucldea dtace v Mahalaob dtace Eucldea dtace betwee pot ad cla ceter : ot wth equal dtace to le o a crcle Mahalaob dtace betwee ad : r ot wth equal dtace to le o a ellpe INF 4300 7 Dcrmat fucto for the ormal dety We aw lat lecture that the mmum-error-rate clafcato ca be computed ug the dcrmat fucto g p Wth a multvarate Gaua we get: t g d Let ut look at th epreo for ome pecal cae: INF 4300 8
INF 4300 9 Cae : =σ I he dcrmat fucto mplfe to ear fucto ug uch a hape o the probablty dtrbuto I d I I d I g Commo for all clae, o eed to compute thee term Sce commo for all clae, a equvalet g a ear fucto of : INF 4300 30 Cae : =σ I Now we get a equvalet formulato of the dcrmat fucto: A equato for the deco boudary g =g ca be wrtte a w= - the vector betwee the mea value h equato defe a hyperplae through the pot 0, ad orthogoal to w If = the hyperplae wll be located halfway betwee the mea value rovg th volve ome algebra, ee the proof at http://wwwbyclbcom/r/utoral/eural_etwork/ch4_htm 0 ad where 0 t t w w g w w 0 0 - - - ad - where 0 w w t
If the feature were depeet =σ I the dcrmat fucto wa mplfed to: ' g h reult ear deco boudare Computg th dcrmat fucto to clafy patter volve computg the dtace from the pot to the mea value for each cla INF 5300 3 he dcrmat fucto whe =σ I that defe the border betwee cla ad the feature pace a traght e he dcrmat fucto terect the e coectg the two cla mea at the pot 0 = - / f we do ot coder pror probablte he dcrmat fucto wll alo be ormal to the e coectg the mea 0 Deco boudary 3
INF 4300 33 Cae : Commo covarace, = If we aume that all clae have the ame hape of data cluter, a tutve model to aume that ther probablty dtrbuto have the ame hape By th aumpto we ca ue all the data to etmate the covarace matr h etmate commo for all clae, ad th mea that alo th cae the dcrmat fucto become ear fucto I g Commo for all clae, o eed to compute Sce commo for all clae, g aga reduce to a ear fucto of INF 4300 34 Cae : Commo covarace, = A equvalet formulato of the dcrmat fucto he deco boudare are aga hyperplae he deco boudary ha the equato: Becaue w = - - ot the drecto of -, the hyperplae wll ot be orthogoal to the e betwee the mea ad where 0 0 t t w w g w w / 0 0 0 w w
Cae 3:, =arbtrary he dcrmat fucto wll be quadratc: t t g W w w where W, t ad w 0 w 0 he deco urface are hyperquadrc ad ca aume ay of the geeral form: hyperplae hyperhpere par of hyperplae hyperellod, Hyperparabolod, he et lde how eample of th I th geeral cae we caot tutvely draw the deco boudare ut by lookg at the mea ad covarace INF 4300 35 Cofuo matrce A matr wth the true cla label veru the etmated cla label for each cla Etmated cla label rue cla label Cla Cla Cla 3 otal # of ample Cla 80 5 5 00 Cla 5 40 5 50 Cla 3 5 50 5 00 otal 0 05 35 450 INF 4300 36
rue / Fale potve / egatve rue potve : atet ha cacer ad tet reult potve rue egatve N: A healthy patet ad a egatve tet reult Eg, tetg for cacer No cacer Cacer N Fale potve F: Healthy patet that get a potve tet reult Fale egatve FN: Cacer patet that get a egatve tet reult Good to have: & N Bad to have: F but th wll probably be detected Wort to have: FN may go u-detected F N F INF 4300 37 Setvty ad pecfcty Setvty: the porto of the data et that teted potve out of all the potve patet teted: Setvty = /+FN he probablty that the tet potve gve that the patet ck Hgher etvty mea that fewer deceae cae go udetected Specfcty: the porto of the data et that teted egatve out of all the egatve patet teted: Specfcty = N/N+F he probablty that a tet egatve gve that the patet ot ck Hgher pecfcty mea that fewer healthy patet are labeled a ck N F N F INF 4300 38
Outler ad doubt I a clafcato problem, we mght wat to detfy outler ad doubt ample We mght wat a deal clafer to report th ample from cla l uual cae th ample ot from ay of the clae outler th ample too hard for me doubt/reect he two lat cae hould lead to a reecto of the ample! INF 4300 39 he covarace matr ad dmeoalty Aume we have S clae ad a d-dmeoal feature vector Wth a fully multvarate Gaua model, we mut etmate S dfferet mea vector ad S dfferet covarace matrce from trag ample ˆ ha d elemet ˆ ha dd+/ elemet Aume that we have M trag ample from each cla Gve M, there a mamum of the acheved clafcato performace for a certa value of d creag beyod th lmt wll lead to wore performace Addg more feature ot alway a good dea! otal umber of ample gve by a rule of thumb: M>0 d S If we have lmted trag data, we ca ue dagoal covarace matrce or regularzato INF 4300 40
he cure of dmeoalty I practce, the cure mea that, for a gve ample ze, there a mamum umber of feature oe ca add before the clafer tart to degrade For a fte trag ample ze, the correct clafcato rate tally creae whe addg ew feature, atta a mamum ad the beg to decreae For a hgh dmeoalty, we wll eed lot of trag data to get the bet performace => 0 ample / feature / cla Correct clafcato rate a fucto of feature dmeoalty, for dfferet amout of trag data Equal pror probablte of the two clae aumed INF 4300 4 Ue few, but good feature o avod the cure of dmeoalty we mut take care fdg a et of relatvely few feature A good feature ha hgh wth-cla homogeety, ad hould deally have large betwee-cla eparato I practe, oe feature ot eough to eparate all clae, but a good feature hould: eparate ome of the clae well Iolate oe cla from the other If two feature look very mlar or have hgh correlato, they are ofte redudat ad we hould ue oly oe of them Cla eparato ca be tuded by: Vual pecto of the feature mage overlad the trag mak Scatter plot Evaluatg feature a doe by trag ca be dffcult to do automatcally, o maual teracto ormally requred INF 4300 4
How do we beat the cure of dmeoalty? Ue regularzed etmate for the Gaua cae Ue dagoal covarace matrce Apply regularzed covarace etmato Geerate few, but formatve feature Careful feature deg gve the applcato Reducg the dmeoalty Feature electo elect a ubet of the orgal feature more INF5300 Feature traform compute a ew ubet of feature baed o a ear combato of all feature INF 5300 Eample : rcpal compoet traform Uuperved, fd the combato that mamzed the varace the data Eample : Fher ear dcrmat Superved, fd the combato that mamze the dtace betwee the clae INF 4300 43 Dtace meaure ued feature electo I feature electo, each feature combato mut be raked baed o a crtero fucto Crtera fucto ca ether be dtace betwee clae, or the clafcato accuracy o a valdato tet et If the crtero baed o eg the mea value/covarace matrce for the trag data, dtace computato fat Better performace at the cot of hgher computato tme foud whe the clafcato accuracy o a valdato data et dfferet from trag ad tetg ued a crtero for rakg feature h wll be lower a clafcato of the valdatto data eed to be doe for every combato of feature INF 5300 44
Dtace meaure betwee clae How do be compute the dtace betwee two clae: Dtace betwee the cloet two pot? Mamum dtace betwee two pot? Dtace betwee the cla mea? Average dtace betwee pot the two clae? Whch dtace meaure? Eucldea dtace or Mahalaob dtace? Dtace betwee K clae: How do we geeralze to more tha two clae? Average dtace betwee the clae? Smallet dtace betwee a par of clae? INF 5300 45 Cla eparablty meaure How do we get a dcato of the eparablty betwee two clae? Eucldea dtace betwee cla mea r - Bhattacharyya dtace Ca be defed for dfferet dtrbuto For Gaua data, t B 8 r r Mahalaob dtace betwee two clae: N r N r r INF 5300 46
Method - Sequetal backward electo Select l feature out of d Eample: 4 feature,, 3, 4 Chooe a crtero C ad compute t for the vector [,, 3, 4 ] Elmate oe feature at a tme by computg [,, 3 ], [,, 4 ], [, 3, 4 ] ad [, 3, 4 ] Select the bet combato, ay [,, 3 ] From the elected 3-dmeoal feature vector elmate oe more feature, ad evaluate the crtero for [, ], [, 3 ], [, 3 ] ad elect the oe wth the bet value Number of combato earched: +/d+d-ll+ INF 4300 47 Method 3: Sequetal forward electo Compute the crtero value for each feature Select the feature wth the bet value, ay Form all poble combato of feature the wer at the prevou tep ad a ew feature, eg [, ], [, 3 ], [, 4 ], etc Compute the crtero ad elect the bet oe, ay [, 3 ] Cotue wth addg a ew feature Number of combato earched: ld-ll-/ Backward electo fater f l cloer to d tha to INF 4300 48
k-nearet-neghbor clafcato A very mple clafer Clafcato of a ew ample doe a follow: Out of N trag vector, detfy the k earet eghbor meaured by Eucldea dtace the trag et, rrepectvely of the cla label Out of thee k ample, detfy the umber of vector k that belog to cla, :,,M f we have M clae Ag to the cla wth the mamum umber of k ample k hould be odd, ad mut be elected a pror INF 4300 49 K-mea cluterg Note: K-mea algorthm ormally mea ISODAA, but dfferet defto are foud dfferet book K aumed to be kow Start wth agg K cluter ceter k radom data pot, or the frt K pot, or K equally pace pot For k=:k, Set k equal to the feature vector k for thee pot Ag each obect/pel the mage to the cloet cluter ceter ug Eucldea dtace Compute for each ample the dtace r to each cluter ceter: r k Ag to the cloet cluter wth mmum r value 3 Recompute the cluter ceter baed o the ew label 4 Repeat from utl #chage<lmt k ISODAA K-mea: plttg ad mergg of cluter are cluded the algorthm k INF 4300 50