资源简介
基于高斯混合模型的视频移动目标检测,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仿真
- 图像缩放,用MATLAB仿真,经典图像缩
- matlab车道线检测
- matlab数据挖掘程序
- 潮流matlab程序
- BFO算法的MATLAB源代码
- 细菌觅食算法(matlab)
- 蚁群算法的matlab源码.rar
- 关于GPS的matlab程序
- 基于Matlab实现的DES加密
- RRT_MATLAB程序带中文注释
- 牛顿——拉夫逊潮流计算的matlab程序
- 何凯明去雾MATLAB代码
- 粒子群优化算法源码matlab
- matlab十大经典算法
- matlab实现三维重建
- matlab实现画最小外接矩形
- Tabu search by matlab to solve TSP
- 基于非支配排序遗传算法处理多目标
- 读取dat文件的matlab代码
- 简单的matlab图像处理GUI程序
- Gabor变换,MATLAB,边缘检测
- MATLAB中计算psnr值的实现
- 频偏估计S&C方法及实现matlab
- 四维超混沌及其图形
- POD_matlab
- 欧盟winner项目关于MIMO信道模型的MAT
- 改进的蜂群算法图像分割MATLAB代码
- 数字调制解调,同步,滤波技术的M
- 基于PCA的图像压缩Matlab代码
评论
共有 条评论