资源简介
这是一个视频图像处理的程序,通过混合高斯分布来建立背景模型,并且提取了运动目标,效果不错!-mixture of gaussians
代码片段和文件信息
% 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(‘H:\viptraffic(1).avi‘);
% ----------------------- 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.00001; % learning rate (between 0 and 1) (from paper 0.01)
thresh = 0.6; % foreground threshold (0.25 or 0.75 in paper)
sd_init = 15; % 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/C; % initial p variable (used to update mean and sd)
pu = 0.01;
psd = 0.0005;
pw = 0.0005;
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
bg_bw(ij)=fr_bw(ij);
% 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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5297 2009-09-17 22:29 mixture_of_gaussians.m
----------- --------- ---------- ----- ----
5297 1
相关资源
- 现代信号处理教程_胡广书随书光盘
- 2D Fast Marching Computations
- 序贯蒙特卡洛可靠性评估.rar
- 基于DCT变换的数字水印算法
- 粒子群算法(pso)标准测试函数验证
- 3种不同语言的BP算法
- FIR滤波器设计
- 三维装箱问题程序
- 算法测试基准函数
- 忆阻神经网络实验
- 带有电压恢复补偿功能的直流微电网
- 自回归滑动平均模型
- 点云数据ply格式
- 直接序列扩频信号的keystone变换捕获
- 大量-小波变换源程序
- 数值计算 函数逼近与曲线拟合 复化梯
- 在vrep环境下的人工势场法仿真
- 5次B样条曲线.rar
- MTD雷达信号处理
- libsvm工具包含网格法查找最优解函数
- libsvm工具包含网格法查找最优解函数
- libsvm工具包含网格法查找最优解函数
- 基于灰度共生矩阵的图像匹配算法
- 完整的QPSK-MSK-QAM-OFDM调制解调m程序.
- 防侧翻控制系统模型 SUV仿真
- 详细注释的MIMO-OFDM信道估计
- LBM boiling
- ls信道估计算法
- 支持向量机SVM多分类算法实现
- OFDM及信道估计的程序
评论
共有 条评论