Displaying frames in GUIDE

I have a necessity to display frames of a video in an axes object (or some other suitable alternative) with the requirement that the various frames can be rendered while maintaining the zoom in level of the axes object. Assume the frames are grayscale and have been stored into a 3 dimensional matrix, the index into the third dimension being used to index frames.
Calling imshow with the parent attribute set to the axes object of my choosing will display the frame. At this point I can use the zoom in controls to zoom into the image data. to display the next frame, my current code calls imshow again with the parent as the same axes object and the image data referenced from the aforementioned 3D array. HOWEVER, the call to imshow resets the zoom, which I believe is set through the XLim and YLim properties of the axes object.
Assuming you have such a 3D array with the frame data for the video, how would you display subsequent frames while maintaining the zoom of the Axes object before the call to imshow?
Something tells me I should keep XLim and YLim of the Axes object untouched and just replace the CData with the data for the new frame. Is this the most effective way to do this?

 Respuesta aceptada

Image Analyst
Image Analyst el 29 de Ag. de 2014

0 votos

You should be able to set "hold on". However that may "pile up" all the images and you could eventually run out of memory. So you might have to call getimage() and delete any existing image object in the axes before calling imshow() to display the next frame. Don't call "cla reset" as it will reset the zoom. You can check whether "cla" by itself will reset the zoom - I don't know.

4 comentarios

John
John el 29 de Ag. de 2014
Thank you Image Analyst . My current understanding about image display in MATLAB is this:
For the sake of illustration lets say we have called the command:
image
which by itself will display some default MATLAB image. That image object is contained in an Axes object which is contained in a Figure object. The color data for the image is determined by the 'CData' property of the image object. The zoom in level is determined by the 'XLim' and 'YLim' properties of the Axes object.
Some experimentation shows that one possible way to achieve my desired effect is to simply swap in the 'CData' property of the Image object with the pixel data for the new frame, leaving the properties of the Axes object untouched. This makes sense to me.
But is it the most efficient way? With respect to efficiency, is there anything objectionable about replacing 'CData' of an Image object?
Image Analyst
Image Analyst el 29 de Ag. de 2014
No. No problem with that. In fact, Sean says that is the fastest, least overhead way of doing it. Everything you say is correct (assuming color data means image pixel values and not color map).
John
John el 29 de Ag. de 2014
Thank you very much Image Analyst.
John
John el 6 de Sept. de 2014
This question has been answered. But reading through the MATLAB documentation, it seems the NextPlot property of Axes can help me achieve the desired effect without having to manipulate CData of the Image . My original problem was that calling the high level image show function, imshow , would cause the Axes properties like XLim and YLim and others which determine the zoom level, to be reset upon subsequent requests for imshow to plot on the same Axes object. It appears setting the NextPlot property of the Axes to ReplaceChildren will preserve those zoom level determining Axes properties between calls to imshow
I imagine setting CData is more efficient and might be a better option if timer objects are being used to play real time video since this would bypass the gauntlet of decision making imshow uses to set things straight
......Just putting it here in case anyone else needs another solution to the original problem......

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 29 de Ag. de 2014

Comentada:

el 6 de Sept. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by