help me to convert code to MATLAB
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ViBe: A universal background subtraction algorithm for video sequences
/ / f i x e d p a r ame t e r s f o r ViBe
/ / number o f samp l e s p e r p i x e l
i n t N = 2 0 ;
/ / r a d i u s o f t h e s p h e r e
i n t R = 2 0 ;
/ / number o f c l o s e samp l e s f o r b e i n g
/ / p a r t o f t h e background ( bg )
i n t ]min = 2 ;
/ / amount o f random s u b s amp l i n g
i n t = 1 6 ;
/ / d a ta
i n t width , h e i g h t ;
/ / c u r r e n t image
byt e image [ wid th ] [ h e i g h t ] ;
/ / background model
byt e s amp l e s [ wid th ] [ h e i g h t ] [N ] ;
/ / background / f o r e g r o u n d s e gme n t a t i o n map
byt e segMap [ wid th ] [ h e i g h t ] ;
/ / background and f o r e g r o u n d i d e n t i f i e r s
byt e b a ck g ro u nd = 0 ;
byt e f o r e g r o u n d = 2 5 5 ;
/ / f o r each p i x e l
f o r ( i n t x = 0 ; x < wid th ; x++){
f o r ( i n t y = 0 ; y < h e i g h t ; y++) {
/ / 1 . Compare p i x e l t o background model
i n t c o u n t = 0 , i n d e x = 0 , d i s t = 0 ;
whil e ( ( c o u n t < ]min ) && ( i n d e x < N ) ) {
/ / Eu c l i d e a n d i s t a n c e c omp u t a t i o n
d i s t = E u c l i dDi s t ( image [ x ] [ y ] ,
s amp l e s [ x ] [ y ] [ i n d e x ] ) ;
i f ( d i s t < R) {
c o u n t ++;
}
i n d e x ++;
}
/ / 2 . C l a s s i f y p i x e l and u p d a t e model
i f ( c o u n t >= ]min ) {
/ / s t o r e t h a t image [ x ] [ y ] 2 background
segMap [ x ] [ y ] = b a ck g ro u nd ;
/ / 3 . Update c u r r e n t p i x e l model
/ / g e t random number b e twe en 0 and −1
i n t r an d = getRandomNumber ( 0 , −1) ;
i f ( r an d == 0 ) { / / random s u b s amp l i n g
/ / r e p l a c e randomly ch o s en sample
r an d = getRandomNumber ( 0 , N−1) ;
s amp l e s [ x ] [ y ] [ r an d ] = image [ x ] [ y ] ;
}
/ / 4 . Update n e i g h b o r i n g p i x e l model
r an d = getRandomNumber ( 0 , −1) ;
i f ( r an d == 0 ) { / / random s u b s amp l i n g
/ / ch o o s e n e i g h b o r i n g p i x e l randomly
i n t xNG , yNG ;
xNG = getRandomNeighbrXCoordinate ( x ) ;
yNG = getRandomNeighbrYCoordinate ( y ) ;
/ / r e p l a c e randomly ch o s en sample
r an d = getRandomNumber ( 0 , N−1) ;
s amp l e s [xNG ] [ yNG ] [ r an d ] = image [ x ] [ y ] ;
}
}
e l s e { / / c o u n t < ]min
/ / s t o r e t h a t image [ x ] [ y ] 2 f o r e g r o u n d
segMap [ x ] [ y ] = f o r e g r o u n d ;
}
}
}
4 Kommentare
Eren
am 21 Nov. 2016
I really want ViBe in matlab too. I found this link but i don't have its account to download. if you can, please help downloading. thanks.
Diarmaid Cualain
am 7 Feb. 2019
Hi Eren,
If you dont have an account to download the files on that page, you can view each file individually, copy the contents to your own *.m file, and run the algorithim then. There are only three files there that you need.
Antworten (1)
Ayush
am 2 Okt. 2016
Best bet is to create a psedu code
also check this link if it helps!
vote if found helpful! ;)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Import, Export, and Conversion finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!