How to make one video out of 3 images?

조회 수: 4 (최근 30일)
Teshan Rezel
Teshan Rezel 2022년 3월 13일
댓글: Teshan Rezel 2022년 3월 14일
Hi folks,
I'm trying to create a single image out of 3 different images, then collate the subsequent images into a video. I'm also trying to write some text onto the middle of the 3 images, that changes with each subsequent frame. I have made the following start but am having limited luck getting it to work!
mainImg = imread([imageMainFolder imageMainFiles(j).name]);
mainImg = mainImg(:,:,1:3);
cropImg = imread([cropsFolder cropFiles(j).name]);
threshImg = im2uint8(imread([threshFolder threshFiles(j).name]));
h = figure;
h(1) = subplot(2, 2, 1);
image(cropImg, "Parent", h(1));
h(2) = subplot(2, 2, 2);
image(threshImg, "Parent", h(2));
h(3) = subplot(2, 2, 3:4);
image(mainImg, "Parent", h(3));
myText = ['Temperature = ' num2str(myTemp(j)) '$^{o}C$'];
RGB = insertText(h, [50 50], myText, 'FontSize',18,'BoxColor', 'black','BoxOpacity',1,'TextColor','white');
image(RGB, 'Parent', axes);
axes.Visible = 'off';
writeVideo(writerObj, RGB);
this is placed inside a loop for j. I close the writerObj when the loop ends.
I'm sure my syntax is wrong so I'd appreciate any advice on how to fix it!

채택된 답변

Image Analyst
Image Analyst 2022년 3월 13일
See attached example. See the second half where I create a movie from images in a folder. The first half deals with extracting frames from an existing movie, getting the mean colors, and (optionally) saving the individual frames to disk.
With only 3 images, you'll need to adjust your FrameRate to be something like 1 or 2 seconds.
  댓글 수: 2
Image Analyst
Image Analyst 2022년 3월 13일
Attached is another, simpler example where I make a movie from the current figure being displayed.
Teshan Rezel
Teshan Rezel 2022년 3월 14일
@Image Analyst fantastic solution as ever, thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by