Issue with plot a video's frame

2 vues (au cours des 30 derniers jours)
Davide Magnelli
Davide Magnelli le 4 Déc 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);
end
processo(:, :, :,frame) = im2double(thisFrame);
end
figure
plot(processo(h,w,1,9))
end
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

Réponses (1)

Elizabeth Reese
Elizabeth Reese le 6 Déc 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:
imshow(processo(:,:,:,9));
will show the 9th frame.

Community Treasure Hunt

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

Start Hunting!

Translated by