Using VideoWriter Function in Matlab to Create Video File of MRIstack
Show older comments
Hello, I am trying to create a .avi file to play the frames from mristack in matlab. I have been trying unsuccessfully to use the function VideoWriter to accomplish this. I know that mristack provides you with 21, 256 by 256 frames and I am not sure how to write them to a video file using VideoWriter. Do you write frame by frame into the .avi file? I tried doing that but it would still not work (it only shows as a black image for a couple seconds). This is the code I am trying.
%%Convert video into binary/monochrome
load mristack
rawData = mristack;
rawData(rawData<127) = 0;
rawData(rawData>=127) = 1;
implay(255*rawData);
trial=rawData(:,:,1);
V= VideoWriter('newtrial2.avi');
open(V);
for t=1:21
writeVideo(V,rawData(:,:,t));
end
close(V);
Sorry if this seems strikingly obvious to someone out there. But I will truly appreciate any help.
Accepted Answer
More Answers (0)
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!