91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

利用多維高斯混合模型,建立背景,然后通過減背景獲得前景區域,多維高斯混合模型具有較強的抗噪聲,較好適應光線變化

資源截圖

代碼片段和文件信息

%?This?m-file?implements?the?mixture?of?Gaussians?algorithm?for?background
%?subtraction.??It?may?be?used?free?of?charge?for?any?purpose?(commercial
%?or?otherwise)?as?long?as?the?author?(Seth?Benton)?is?acknowledged.


clear?all

%?source?=?aviread(‘C:\Video\Source\traffic\san_fran_traffic_30sec_QVGA‘);
source?=?aviread(‘..\test_video\san_fran_traffic_30sec_QVGA_Cinepak‘);

%?-----------------------??frame?size?variables?-----------------------

fr?=?source(1).cdata;???????????%?read?in?1st?frame?as?background?frame
fr_bw?=?rgb2gray(fr);?????%?convert?background?to?greyscale
fr_size?=?size(fr);?????????????
width?=?fr_size(2);
height?=?fr_size(1);
fg?=?zeros(height?width);
bg_bw?=?zeros(height?width);

%?---------------------?mog?variables?-----------------------------------

C?=?3;??????????????????????????????????%?number?of?gaussian?components?(typically?3-5)
M?=?3;??????????????????????????????????%?number?of?background?components
D?=?2.5;????????????????????????????????%?positive?deviation?threshold
alpha?=?0.01;???????????????????????????%?learning?rate?(between?0?and?1)?(from?paper?0.01)
thresh?=?0.25;??????????????????????????%?foreground?threshold?(0.25?or?0.75?in?paper)
sd_init?=?6;????????????????????????????%?initial?standard?deviation?(for?new?components)?var?=?36?in?paper
w?=?zeros(heightwidthC);??????????????%?initialize?weights?array
mean?=?zeros(heightwidthC);???????????%?pixel?means
sd?=?zeros(heightwidthC);?????????????%?pixel?standard?deviations
u_diff?=?zeros(heightwidthC);?????????%?difference?of?each?pixel?from?mean
p?=?alpha/(1/C);????????????????????????%?initial?p?variable?(used?to?update?mean?and?sd)
rank?=?zeros(1C);??????????????????????%?rank?of?components?(w/sd)


%?---------------------?initialize?component?means?and?weights?-----------

pixel_depth?=?8;????????????????????????%?8-bit?resolution
pixel_range?=?2^pixel_depth?-1;?????????%?pixel?range?(#?of?possible?values)

for?i=1:height
????for?j=1:width
????????for?k=1:C
????????????
????????????mean(ijk)?=?rand*pixel_range;?????%?means?random?(0-255)
????????????w(ijk)?=?1/C;?????????????????????%?weights?uniformly?dist
????????????sd(ijk)?=?sd_init;????????????????%?initialize?to?sd_init
????????????
????????end
????end
end

%---------------------?process?frames?-----------------------------------

for?n?=?1:length(source)

????fr?=?source(n).cdata;???????%?read?in?frame
????fr_bw?=?rgb2gray(fr);???????%?convert?frame?to?grayscale
????
????%?calculate?difference?of?pixel?values?from?mean
????for?m=1:C
????????u_diff(::m)?=?abs(double(fr_bw)?-?double(mean(::m)));
????end
?????
????%?update?gaussian?components?for?each?pixel
????for?i=1:height
????????for?j=1:width
????????????
????????????match?=?0;
????????????for?k=1:C???????????????????????
????????????????if?(abs(u_diff(ijk))?<=?D*sd(ijk))???????%?pixel?matches?component
????????????????????
???????????????????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????5224??2008-12-11?22:37??mixture_of_gaussians.m

評論

共有 條評論