video in a figure
17 views (last 30 days)
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 = ;
%Watch the video
figure(1), movie(mov, 1, obj.FrameRate), title('Original movie');
John D'Errico on 10 Mar 2020
Usually the trick is to use the command:
to force a set of axes to fit tightly to what is plotted inside them, minimizing the white space.
Cedric Wannaz on 10 Mar 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.: