issues with im2frame and getframe
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Image Analyst
le 9 Juin 2016
Modifié(e) : Image Analyst
le 9 Juin 2016
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 commentaire
Fabrizio Marangio
le 10 Juin 2016
Modifié(e) : Fabrizio Marangio
le 10 Juin 2016
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!