You are on page 1of 8

BI TP NHM PHN 4

Trong phn bn ny cc bn s lm quen vi cc thut ton nng cao. Cc nhm ch cn trin khai bi tp no cn thit phc v nho topic ca mnh. V d: Nhm chn Canny s phi trin khai Canny Nhm chn phn vng vi tch ngng t ng s phi trin khai cc thut ton tch ngng t ng Nhm chn nhn din nh theo khng gian th phi trin khai cc thut ton khong cch ln nht, k trung bnh v k lng ging Nhm chn nhn chp s phi trin khai mt trong ba bi tp trn v nhn chp l bi tp bt buc

Trong tt c cc bi tp nh a l nh c 256 mc xm. Gi tr max v min ca cc im nh l 0 v 255.

K thut Canny
Vit hm canny sao cho nu: b = canny(a,s,gx,gy,ht,lt) vi a l ma trn th hin nh u vo s l ma trn lm trn gx l ma trn o hm bc 1 chiu x gy l ma trn o hm bc 1 chiu y ht l ngng cao khi tch im chc chn l bin lt l ngng thp ln theo bin

th b l nh kt qu ca vic tm bin vi canny. V d: nh a

a= [ ]

Vi s =[

], gx =[

], gy =[

], ht=127,hl=64

th agm = [ ]

(ma trn ln ca o hm)

v aga = [ ]

(ma trn hng ca o hm)

trong m trn hng th cc s tng ng vi hng nh sau [

v kt qu l b = [ ]

Vi s =[

], gx =[

], gy =[

], ht=129,hl=64

th kt qu l b = [ ]

Vi s =[

], gx =[

], gy =[

], ht=150,hl=129

th kt qu l b = [ ]

Vi s =[

], gx =[

], gy =[

], ht=127,hl=64

th kt qu l b = [ ]

Vi s =[

], gx =[

], gy =[

], ht=127,hl=64

th kt qu l b = [ ]

Lm trn histogram
Vit hm histsmooth sao cho nu: b = histsmooth (a,w) vi a l histogram u vo w l chiu rng ca hm smooth

th b l histogram sau khi lm trn. V d: histogram a a=[ vi w = 5 th b = [ vi w = 3 th b = [ ] ] ]

vi w = 4 th hm nn bo li vi error('...'); ??? Error using ==> histsmooth at ... w should be an odd number not 4

Thut ton ng iu
Vit hm ridandcal sao cho nu: t = ridandcal (a) vi a l histogram u vo

th t l ngng thu c t thut ton ng iu V d: vi a = [ th t = 5 ]

vi a = [ th t = 3

Thut ton i xng nn


Vit hm symbg sao cho nu: t = symbg (a,b,p) vi a l histogram u vo b =1 nu nn sng hn b=0 nu nn ti hn p l t l phn trm ta mun giu li nn (v d p=95)

th t l ngng thu c t thut ton i xng nn V d: a=[ vi b = 1 v p=95 th t = 4 vi b = 1 v p=80 th t = 5 vi b = 0 v p=80 th t = 9 ]

Thut ton tam gic


Vit hm triangle sao cho nu: t = triangle(a , b) vi a l histogram u vo b =1 nu nn sng hn b=0 nu nn ti hn

th t l ngng thu c t thut ton tam gic Lu , chng ta c th gi nh l nh min ca tam gic l v tr 0 nu nn sng v v tr mc sng nht nu nn l ti V d: a=[ vi b = 1 th t = 7 ]

Thut ton k lng ging


Vit hm knn sao cho nu: class = knn(sample, ls , k) vi sample l i tng cn phn loi ls l tp hp mu k l s lng ging cn tm phn loi

th class l phn loi ca knn v sample da vo m k lng ging gn sample trong ls V d: sample = [ ]

ls = [ ]

mi dng l mt mu, bao gm 2 tham s v phn loi

k = 2 th class = 0 nu sample = [ ] th class = 1

Thut ton k lng ging nng cp


Vit hm wknn sao cho nu: class = wknn(sample, ls , k) vi sample l i tng cn phn loi ls l tp hp mu k l s lng ging cn tm phn loi

th class l phn loi ca wknn v sample da vo k lng ging gn nht vi sample, tuy nhin phiu bu c gi tr t l nghc vi khong cch ca lng ging n i tng V d: sample = [ ]

ls = [ ]

mi dng l mt mu, bao gm 2 tham s v phn loi

k = 5 th class = 0

Thut ton khong cch ln nht


Vit hm maxdis sao cho nu: [class,cp] = maxdis (sample, ls, t) vi sample l i tng cn phn loi ls l tp hp mu t l ngng

th class l phn loi ca maxdis v sample da vo cc vng m maxdis chia ra cc vng ny s c th hin bng cp (l danh sch cc im tm cc vng) V d: vi sample = [ ls = [ t=2 th class = 1 v cp = [ nu sample = [ ] ] ]

] mi dng l mt mu, bao gm 2 tham s

ls = [

] v t=2

th class = 1 v cp = [ nu sample = [ ]

ls = [

] v t=2

th class = 2 v cp = [

Thut ton k trung bnh


Vit hm kmean sao cho nu: [class,cp] = kmean (sample, ls, k) vi sample l i tng cn phn loi ls l tp hp mu k l s tp mun phn loi

th class l phn loi ca kmean v sample da vo k vng m kmean chia ra k vng ny s c th hin bng cp (l danh sch cc im tm cc vng) V d: sample = [ ls = [ k=2 th class = 1 v cp = [ hoc class = 2 v cp = [ hoc class = 2 v cp = [ ] ] ] ]

] mi dng l mt mu, bao gm 2 tham s

y kmean c th cho ra cc kt qu khc nhau mi ln chy (l do l v k im u tin c khi to mt cch ngu nhin)