加断点看一下files结构体数组的维度,从报错山来看,files的维度应该小于761,所以files(761)的时候会报错。
1
clear
close all
clc
% ----------------------- frame size variables -----------------------
%framedata = imread('./pic/b00001.bmp'); % read in 1st frame as background frame
framedata = imread('E:\data\dataset\dynamicBackground\fall\input\in000001.jpg z');
fr_gray = rgb2gray(framedata); % convert background to greyscale
fr_gray = double(fr_gray);
fr_size = size(fr_gray);
width = fr_size(2);
height = fr_size(1);
fg = zeros(height, width);
bg_bw = zeros(height, width); % background mask
% --------------------- initialize variables -------------------------------------
ClassNum = 4; % class number
Tpthresh = 0.64; % threshhold of milarity of the histogram
Tbthresh = 0.4; % threshhold of background chek
Radcomp = 6; % radius for LBP computing
Neighbours = 8; % Samples for LBP computing
HistRad = 5; % radius for local histogram compute
Alpha = 0.001; % learning rate
Mapping = getmapping(Neighbours/2,'ri2'); % getting a mapping for LBP codes in a neighbourhood of SAMPLES sampling points.
bins = (max(max(Mapping))+1); % number of histogram bins
BackgroundModel = zeros(height,width,ClassNum,2*bins); % creating background model
BackgroundModelPara = ones(height,width,ClassNum)/ClassNum; % creating parameter matrix %初始化权值
LBPCodeImage = zeros(height,width);
LBPCodeImageMag = zeros(height, width);
LocalLBPHistImage = zeros(height, width, 2*bins);
LocalLBPHistImageMag = zeros(height, width, bins);
%------------------------ inilization ------------------------------------
[LBPCodeImage, LBPCodeImageMag] = lbpcompute(fr_gray, Radcomp, Neighbours); % computing the lbp code image
LocalLBPHistImage = LocalLBPHist(LBPCodeImage, LBPCodeImageMag, HistRad, Mapping); % computing the local histogram
for i=1:height % initilization the background with first frame
for j=1:width
for k=1:ClassNum
BackgroundModel(i, j, k, :) = LocalLBPHistImage(i,j,:);
end
end
end
%--------------------- process frames -----------------------------------
LBPCodeImageTemp = zeros(height,width);
LBPCodeImageTempMag = zeros(height,width);
LocalLBPTemp = zeros(height,width,2*bins);
LocalLBPTempMag = zeros(height,width, bins);
SamplePath1 = 'E:\data\dataset\dataset\dynamicBackground\fall\input\'; %存储图像的路径
fileExt = '*.jpg'; %待读取图像的后缀名
files = dir(fullfile(SamplePath1,fileExt)); %fullfiE: 利用文件各部分信息创建 合成完整文件名,主要用于路径的拼接。
%dir函数 读取一个文件夹下的所有的文件,并存储到一个结构体中。在结构体中存储了该文件夹下所有的文件的名字以及文件的创建日期
len1 = size(files,1);
%遍历路径下每一幅图像
%for numberframe = 2:632
for p = 761: 761%len1
fileName = strcat(SamplePath1,files(p).name); %strcat函数 拼接两个字符串形成路径
您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632