フィルターのクリア

help me to convert code to MATLAB

1 回表示 (過去 30 日間)
Alaa A. Hussain
Alaa A. Hussain 2016 年 9 月 30 日
コメント済み: Diarmaid Cualain 2019 年 2 月 7 日
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 件のコメント
Eren
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
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
Ayush 2016 年 10 月 2 日
Best bet is to create a psedu code
also check this link if it helps!
vote if found helpful! ;)

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by