video in a figure

22 visualizaciones (últimos 30 días)
C.G.
C.G. el 10 de Mzo. de 2020
Respondida: Cedric el 10 de Mzo. de 2020
I have imported a video into MATLAB but when I play this in a figure, the figure dimensions are different to that of the video. Is there a way to change this and make it fit?
%Input video using videoreader and name it 'obj'
obj = VideoReader('highamballvideo.mov')
%Tell it to read the frames in the video where 20 is start and 34 finish
frames_no = [20:34];
vidFrames = read(obj,[20 34]);
%Tell it to get the number of individual frames in the video
numFrames = size(vidFrames,4);
%Get individual frames
%Colormap is a table of colors used for index color videos
%c.data is an image sequence matrix
%How many times you repeat a function in a loop is defined by 'k'. k = the
%range of values the for loop will run through before ending.
for k = 1: numFrames
mov(k).cdata = vidFrames(:,:,:,k);
mov(k).colormap = [];
end
%Watch the video
figure(1), movie(mov, 1, obj.FrameRate), title('Original movie');

Respuestas (2)

John D'Errico
John D'Errico el 10 de Mzo. de 2020
Usually the trick is to use the command:
axis tight
to force a set of axes to fit tightly to what is plotted inside them, minimizing the white space.
  1 comentario
C.G.
C.G. el 10 de Mzo. de 2020
just tried your suggestion and it hasnt worked unfortunatley, video still coming out exactly the same

Iniciar sesión para comentar.


Cedric
Cedric el 10 de Mzo. de 2020
The reason is indicated in the doc: "The movie function uses a default figure size of 560-by-420 and does not resize figures to fit movies with larger or smaller frames. To accommodate other frame sizes, you can resize the figure to fit the movie."
There are many threads about it, e.g.:

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by