资源简介
基于高斯混合模型的视频移动目标检测,matlab代码,喜欢的可以学习一下。

代码片段和文件信息
clear all;
close all;
Video = input(‘Enter the name of the video file:‘ ‘s‘);
if isempty(Video)
error(‘myApp:argChk‘ ‘You did not enter a video file!‘)
end
inputVideo = aviread(Video);
fr = inputVideo(1).cdata; % read in 1st frame as background frame
fr_bw = rgb2gray(fr); % convert background to greyscale
fr_size = size(fr); % get the size of the frame
width = fr_size(2); % get the width of the frame
height = fr_size(1); % get the height of the frame
foreground = zeros(height width); % initialize variable to store foreground
background = zeros(height width); % initialize variable to store background
%
K = 3; % number of gaussian components (can be upto 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)
foregroundThreshold = 0.25; % foreground threshold (0.25 or 0.75 in paper)
sd_initial = 6; % initial standard deviation (for new components) var = 36 in paper
weight = zeros(heightwidthK); % initialize weights array
mean = zeros(heightwidthK); % pixel means
standardDeviation = zeros(heightwidthK); % pixel standard deviations
diffFromMean = zeros(heightwidthK); % difference of each pixel from mean
learningRate = alpha/(1/K); % initial p variable (used to update mean and sd)
rankComponent = zeros(1K); % rank of components (w/sd)
% initialize components for the 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:K
mean(ijk) = rand*pixel_range; % means random (0-255) it initialzes the mean to some random value.
weight(ijk) = 1/K; % weights uniformly dist
standardDeviation(ijk) = sd_initial; % initialize to sd_init
end
end
end
% Applying the proposed algorithm to the video
for n = 1:length(inputVideo)
% reading the frames.
fr = inputVideo(n).cdata;
% converting the frames to grayscale.
fr_bw = rgb2gray(fr);
% calculating the difference of each pixel values from mean.
for m=1:K
diffFromMean(::m) = abs(double(fr_bw) - double(mean(::m)));
end
% update gaussian components for each pixel values.
for i=1:height
for j=1:width
match = 0; % its changed to 1 if the component is matched
for k=1:K
% pixel matches component
if (abs(diffFromMean(ij
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7375 2018-02-01 20:21 RavdeepJohar.m
- 上一篇:循环码的matlab仿真
- 下一篇:升余弦滤波器和根升余弦滤波器
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论