我是图像处理的新手。我想做的就是消除人类的阴影。我试着实现this paper的阴影检测,但我收到的错误是:
指数超出矩阵维度。
Bpos出错(第37行) w =(cfv(i,j)/ pv(i,j));
请帮帮我。非常感谢提前。
以下是我所做的代码:
mov = VideoReader('person05_walking_d4_uncomp.avi');
p=imread('c.png');
p=rgb2hsv(p);
ph=p(:,:,1);
ps=p(:,:,2);
pv=p(:,:,3);
alphaV=0.2;
betaV=0.8;
opFolder = fullfile('F:\imagelab', 'Bpos');
if ~exist(opFolder, 'dir')
mkdir(opFolder);
end
numFrames = mov.NumberOfFrames;
numFramesWritten = 0;
for t = 1 : numFrames
currFrame = read(mov, t);
currFrame=rgb2hsv(currFrame);
figure;imshow(currFrame);
cfh=currFrame(:,:,1);
figure;
imshow(cfh);
cfs=currFrame(:,:,2);
figure;imshow(cfs);
cfv=currFrame(:,:,3);
figure;imshow(cfv);
[m,n]=size(currFrame);
single=zeros(m,n);
for i=1:m
for j=1:n
% a=cfv(i,j);
% progIndication = sprintf('Wrote frame %d.',a);
% disp(progIndication);
w= (cfv(i,j)/pv(i,j));
progIndication = sprintf('Wrote frame %d.',w);
disp(progIndication);
sat=cfs(i,j)-ps(i,j);
progIndication = sprintf('sat frame %d.',w);
disp(progIndication);
hue=cfh(i,j)-ph(i,j);
progIndication = sprintf('hue frame %d.',w);
disp(progIndication);
if(w>=alphaV && w<=betaV && sat<=-0.3 && hue <=0.2)
single(i,j)=1;
else
single(i,j)=0;
end
end
end
imshow(single);
opBaseFileName = sprintf('%3.3d.png', t);
opFullFileName = fullfile(opFolder, opBaseFileName);
imwrite(single, opFullFileName, 'png');
end
end