我需要在Matlab图中尽可能快地显示更新的图像.处理每个图像然后显示.但是,彩色图像的显示速度非常慢.
例如,当我运行以下代码时
videoObj = VideoReader('sample.avi');
nFrames = videoObj.NumberOfFrames;
h = videoObj.Height;
w = videoObj.Width;
mov(1:nFrames) = struct('cdata', zeros(h, w, 3, 'uint8'), 'colormap', []);
for k = 1 : nFrames
mov(k).cdata = read(interObj, k);
end
tic
for i=1:nFrames
frame = mov(i).cdata;
image(frame);
drawnow;
end
secPerFrame = toc/nFrames
更新每个帧需要secPerFrame = 0.012秒.每帧是640×480像素的RGB图像.因此,如果我想以每秒30帧处理视频流,则在减去与图像显示相关的开销之后,实际图像处理“仅”0.033 – 0.012 = 0.021秒.
有没有更快的方法来更新Matlab中的图像对象?