你的问题很简单
处理图像所需的每 10 帧都必须进行迭代。
您可以使用 subplot 功能在一个图形中绘制不同的图形。
subplot(n,m,p) = takes 3 arguments
n = number of rows
m = number of columns
p = location of current figure (from left to right , top to bottom flow)
因此subplot(1,2,2) 会将一个图形分成两部分(单行和两列)并在第二列中绘制一个图形。
waitforbuttonpress 将允许您暂停屏幕,直到您在图形上单击鼠标或按任意键。
幸运的是我做了一些非常相似的事情
我改变了一些代码,我认为这就是你想要做的。
由于 cmets,代码是不言自明的......
% get a video file
[f, p] = uigetfile({'*.avi'});
% create a video reader object.
frames = VideoReader([p,f]);
get(frames);
% get the framerate of video
fps = frames.FrameRate;
% get the number of frames in video
nframes = frames.NumberOfFrames;
pickind = 'jpg';
% create a figure to plot on
figure,
% iterate for each 10th frame in image (in step of 10)
for i = 10:10:nframes
%Use your fps to calculate time elasped
disp('Time Elasped:');
disp(i/fps);
% read a frame to image
I = read(frames, i);
% in first row & first column 1st plot will be the original image
% itself
subplot(1,2,1);
imshow(I) ;
% in first row & second column 2nd plot will be a graph of
% processed image (do your image processing here)
subplot(1,2,2);
imhist(rgb2gray(I));
% Hit a key to process next 10th frame from video
k = waitforbuttonpress ;
end
%close the figure
close
要正确注释您的图,请了解 figures, plots and subplots,因为 matlab 文档本身有很多材料。
快乐学习