help me to convert code to MATLAB
이전 댓글 표시
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
Image Analyst
2016년 9월 30일
Sorry, we can't do that. We don't even know what those functions are. Plus it's asking too much from us. It's not like we could convert that program, with it's hundreds of lines of missing code, in a few minutes. It could take hours or more, assuming we could even get the missing functions. I suggest you learn MATLAB and do it yourself, or ask the author if they have it already, or hire someone to do it for you.
Walter Roberson
2016년 9월 30일
And the spacing is a real mess.
Eren
2016년 11월 21일
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
2019년 2월 7일
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.
답변 (1개)
Ayush
2016년 10월 2일
0 개 추천
Best bet is to create a psedu code
also check this link if it helps!
vote if found helpful! ;)
카테고리
도움말 센터 및 File Exchange에서 Image Segmentation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!