Filter löschen
Filter löschen

issues with im2frame and getframe

4 Ansichten (letzte 30 Tage)
Fabrizio Marangio
Fabrizio Marangio am 9 Jun. 2016
Bearbeitet: Fabrizio Marangio am 10 Jun. 2016
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)

Antworten (1)

Image Analyst
Image Analyst am 9 Jun. 2016
Bearbeitet: Image Analyst am 9 Jun. 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 Kommentar
Fabrizio Marangio
Fabrizio Marangio am 10 Jun. 2016
Bearbeitet: Fabrizio Marangio am 10 Jun. 2016
I have another question, if i use this code:
s=size(handles.img);
res_img=imresize(handles.img,[128 128]);
for i=1:s(3)
handles.frame(i)=im2frame(res_img(:,:,i),handles.map);
end
axes(handles.video_axes)
movie(handles.frame,3,3)
i see the video in my axes at 128x128 but if i open another image i see the new video plus the old video. Basically i can't reset the first video i saw

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by