issues with im2frame and getframe
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi all, i'm trying to make a video with some frames in a gui, i tried im2frame and getframe to pick the frames from my images but i have some problems. If i use im2frame and then set the video with movie i'm not able to set the size of the video so it's smaller or larger of the axes of my gui. If i use getframe the problem of the size is solved but i have also the visualization of all the images in my axes and then the video, basically i have a very fast slide of images before the start of the video. There is a way to solve these issues? Thanks
This is an example of the code i'm using:
s=size(handles.img);
for i=1:s(3)
imagesc(handles.img(:,:,i)),colormap(gray(256)),axis off;
frame(i)=getframe;
end
axes(handles.Immagine_Originale)
movie(frame,3,3)
댓글 수: 0
답변 (1개)
Image Analyst
2016년 6월 9일
편집: Image Analyst
2016년 6월 9일
Why are you even using iamgesc() and then getframe() at all? There is no need. You can make the movie directly from your 3-D image without even displaying them at all if you don't want to. Just do something like this:
% Convert the 3-D array to a movie.
% Preallocate myMovie, which will be an array of structures.
% First get a cell array with all the frames.
[vidHeight, vidWidth, numberOfFrames] = size(handles.img);
allTheFrames = cell(numberOfFrames,1);
allTheFrames(:) = {zeros(vidHeight, vidWidth, 3, 'uint8')};
% Next get a cell array with all the colormaps.
allTheColorMaps = cell(numberOfFrames,1);
allTheColorMaps(:) = {zeros(256, 3)};
% Now combine these to make the array of structures.
myMovie = struct('cdata', allTheFrames, 'colormap', allTheColorMaps)
for frame = 1 : numberOfFrames
% Read the image in from disk.
thisFrame = handles.img(:,:, frame);
% Convert the image into a "movie frame" structure.
myMovie(frame) = im2frame(thisFrame);
% Write this frame out to a new video file.
writeVideo(writerObj, thisFrame);
end
close(writerObj);
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!