Issue with plot a video's frame

1 view (last 30 days)
Davide Magnelli
Davide Magnelli on 4 Dec 2017
Answered: Elizabeth Reese on 6 Dec 2017
I am trying to plot the following figure
if true
folder = fileparts(which('Field_adv_diff_2D.avi'));
movieFullFileName = fullfile(folder,'Field_adv_diff_2D.avi');
videoObject = VideoReader(movieFullFileName);
numberOfFrames = videoObject.NumberOfFrames;
for frame = 1:numberOfFrames
thisFrame = read(videoObject,frame);
if frame == 1
h = size(thisFrame,1);
w = size(thisFrame,2);
processo = zeros(h, w, 3, numberOfFrames);
processo(:, :, :,frame) = im2double(thisFrame);
The ninth frame of the video Field_adv_diff_2D.avi as shown in the code above. The figure returned is empty, anyone might say me if am I doing the right thing about my task? Thanks in advance Davide

Answers (1)

Elizabeth Reese
Elizabeth Reese on 6 Dec 2017
I believe what you are trying to do is view the 9th frame of this video. It looks like your frames are RGB images of size h x w x 3. What you are currently plotting is only the value of the red component in the bottom rightmost pixel of your image. Nothing shows up because you plot it as if it were a line, but there is only one point.
In order to do view this frame, you can use the function imshow on the whole RGB matrix.
For example:
will show the 9th frame.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!