It's time for our first hands-on example in video processing. Let's use the following steps to import and play-back the video we used before (singleball.avi
):
First, we import the video in a matrix, using
VideoReader
followed byread
:>> vObj = VideoReader('singleball.avi'); >> video = read(vObj); % read in all frames from video object
Now, it is time to use the number of frames to create a video structure like the one that is generated by
aviread
. Remember, for truecolor frames, it consists of acdata
field with all the pixel values and an emptycolormap
field:>> numOfFrames = get(vObj, 'NumberOfFrames'); >> for i = 1:numOfFrames, vid(i).cdata = video(:,:,:,i); % Frames are stored in cdata vid(i).colormap = []; % Colormap is empty end
Since we have stored our video in the necessary format, we can now create the figure in which we have to display it and then call
movie
:>> hf = figure; >> movie(vid)
The...