I need to display updated images as quickly as possible in a Matlab figure. Each image is processed and then displayed. However, the display speed of color images is rather slow. For example, when I run the following code
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
seconds is required to update each frame. Where each frame is an RGB image of 640x480 pixels. Therefore, if I want to process a video stream at a speed of 30 frames per second, this leaves "only" 0.033 - 0.012 = 0.021
seconds for the actual image processing after subtracting the service data associated with the image display.
Is there a faster way to update image objects in Matlab?
source share