problem with creating video from black and white images
Mostra commenti meno recenti
Hi folks,
I am trying to create a video using Black and White images using the following code:
writerObj = VideoWriter(threshVideoName);
writerObj.FrameRate = 10;
open(writerObj);
for j = 1:numThresholds
image = imread([threshFolder threshFiles(j).name]);
frame = im2frame(uint8(image), gray);
writeVideo(writerObj, frame);
end
however, the output is entirely black! I've tried gray(256) and gray(0) but get the same issue. I believe I am not using the correct colour map, although I'm uncertain if this is the problem! If anyone can help me fix this issue, it would be most appreciated!
Risposta accettata
Più risposte (2)
yanqi liu
il 8 Mar 2022
writerObj = VideoWriter(threshVideoName);
writerObj.FrameRate = 10;
open(writerObj);
for j = 1:numThresholds
image = imread([threshFolder threshFiles(j).name]);
frame = im2frame(im2uint8(mat2gray(image)), gray);
writeVideo(writerObj, frame);
end
1 Commento
Image Analyst
il 8 Mar 2022
Remember to call
close(writerObj);
after the loop. And don't call your variable image because image is the name of a very important built-in variable.
Image Analyst
il 8 Mar 2022
0 voti
Attached is a demo that takes a video and minds some things in the frames (like mean intensity), and (optionally) writes the video frames out to disk. The second part of the demo shows you how to read in frames from individual disk files and create a move from them. Also attached are how to make a movie out of a surface you create from data (two versions : color and grayscale).
Categorie
Scopri di più su Convert Image Type in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!