资源简介
利用多维高斯混合模型,建立背景,然后通过减背景获得前景区域,多维高斯混合模型具有较强的抗噪声,较好适应光线变化
代码片段和文件信息
% 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
- 上一篇:系统辨识参数辨识matlab程序
- 下一篇:消失点检测程序
相关资源
- 消失点检测程序
- 系统辨识参数辨识matlab程序
- 解决MATLab2012b Symbolic_Toolbox License 许可
- 血管三维模型重建
- matlab 三维立体图生成器双眼视差
- 给予MATLAB的DSB调制解调代码
- camshift matlab 源代码
- Matlab求解微分方程(组)及偏微分方
- 神经元HH方程Matlab
- 基于最近邻算法的股票价格预测matl
- 信号检测贝叶斯
- matlab级联STATCOM仿真
- 扩展汉明码的硬判决+软判决+SPA算法译
- 指派问题matlab匈牙利算法
- 卷积码编码译码MATLAB仿真程序
- cao法确定相空间的维数
- matlab源码--散点数据生成格网、等高线
- graphcut用于图像分割的matlab代码
-
MATLAB excelli
nk - MATLAB R2017a 支持Microsoft Visual Studio 2
- 基于G.Rilling所写EMD的MATLAB代码的中文
- SVM线性、非线性可分matlab demo
- 布丰投针实验 MATLAB仿真 以及报告
- EZW_Matlab.rar
- matlab交流异步电动机软起动仿真
- 光流场计算 MATLAB 源码 optical flow
- 用matlab实现牛顿迭代法
- 闪耀光栅输出光强分布仿真
- Max-flow/min-cut工具箱Bk_matlab
- 小波软阈值的去噪的MATLAB代码.rar
评论
共有 条评论