video in a figure
15 ビュー (過去 30 日間)
古いコメントを表示
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');
0 件のコメント
回答 (2 件)
John D'Errico
2020 年 3 月 10 日
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.
Cedric
2020 年 3 月 10 日
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.:
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!