资源简介
经典的高斯混合模型背景建模+肤色检测的Matlab实现
代码片段和文件信息
% 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(‘G:\Matlab Exercises\Background\cap.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.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 = 10; % 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)
w_fg=fspecial(‘average‘[5 5]);
% --------------------- 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
match = 1; % variable to sign
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2120 2013-03-14 16:20 skin_color.m
文件 5615 2013-03-27 12:04 mixture_of_gaussians.m
- 上一篇:MATLAB图像去雾处理
- 下一篇:覆盖算法
相关资源
- Gaussian Particle Filter 高斯粒子滤波算法
- GMM 混合高斯背景建模
- 三相不平衡配电网的潮流计算
- 产生拉盖尔高斯光束
- SGP
- 仿生图像增强法(image enchance)
- 高斯混合模型(GMM)
- 高斯过程回归算法工具箱
- 高斯核支持向量数据描述(SVDD)方法
- GMM,HMM的语音识别,说话人识别源码
- 高斯过程回归
- matlab仿真qpsk在高斯信道和瑞利衰落信
- 高斯光束传输
- 厄米高斯光束MATLAB仿真代码
- MATLAB 高斯过程回归代码GPR
- MATLAB实现高斯赛德尔迭代法
- 混合高斯背景建模 matlab
- matlab求高斯白噪声的功率谱
- usm锐化高斯滤波matlab
- 高斯变异改进基本萤火虫群优化算法
- 基于高斯扰动的布谷鸟算法优化svr网
- Gaussian-process-regression 高斯过程回归及
- 前景检测程序(Foreground-detection-proc
- matlab生成高斯随机粗糙表面 (Fracta
- 使用 拉盖尔函数、缔合拉盖尔函数画
- 改进的混合高斯背景模型
- 三正弦叠加高斯白噪声信号源进行频
- DoGfilters DOG高斯差分实现物体识别中的
- GMM 本代码建立高斯混合模型(高斯多
- STFT 短时傅里叶变换的一些简单的演示
评论
共有 条评论