基本上,我想循环所有视频帧,从背景图像中减去每一帧,并使用子图或数字显示结果,即 subtractedImg .
vidObj = VideoReader('test3.mp4');
width = vidObj.Width;
height = vidObj.Height;
subtractedImg = zeros([width height 3]);
videoFrames = [];
k = 1;
while hasFrame(vidObj)
f = readFrame(vidObj);
f=uint8(f);
videoFrames = cat(numel(size(f)) + 1, videoFrames, f);
k = k+1;
end
backgroundImg = median(videoFrames,4);
i=1;
Problem here 我在这里使用的子图,在这个循环中不显示输出 . 仅显示一个 Headers 为"last one"的图形 .
while hasFrame(vidObj)
frame = readFrame(vidObj);
subtractedImg=imabsdiff(frame,backgroundImg);
figure(i); imshow(subtractedImg);
% subplot(5,5,i),imshow(subtractedImg);
%uncommenting above line does not work, subplot not shown
if(i < 20)
i= i+1;
end
end %end while
subplot(1,2,1),imshow(subtractedImg),title('last one');
如何使用子图显示每个图像?例如,使用5x5子图,如果我想显示25个减影图像,为什么 subplot(5,5,i),imshow(subtractedImg); 不起作用?