How can I handle images?
Mostrar comentarios más antiguos
I have three images displaying in three axes on a figure. I want to get them handles so I can browse them using a slider.
How do I give them handles?
1 comentario
"How do I give them handles?"
hnd = imshow(...)
Respuestas (1)
Image Analyst
el 20 de Jun. de 2018
You can flip them easier without handles:
yourImage = fliplr(yourImage);
imshow(yourImage);
17 comentarios
Stelios Fanourakis
el 20 de Jun. de 2018
Image Analyst
el 20 de Jun. de 2018
I don't believe so, but whatever. I never need handles to actual images and so I don't know why you would either. Maybe an axes, but never an image in an axes.
Stephen23
el 21 de Jun. de 2018
I do this quite often: just like it is possible to change the XData and YData of a line object (rather than calling plot again) it is faster to simply change the Cdata of an image object using its handle, and means that you can create just one handle and pass that around your code. For example this is very useful if you want to define your own colorbars or similar images that change with sliders/callbacks, and is much faster than calling imshow / whatever each time. Very useful!
Stelios Fanourakis
el 21 de Jun. de 2018
Stelios Fanourakis
el 21 de Jun. de 2018
Stelios Fanourakis
el 21 de Jun. de 2018
Adam
el 21 de Jun. de 2018
You are trying to set CData on an axes handle, you need the image handle.
Stelios Fanourakis
el 21 de Jun. de 2018
Adam
el 21 de Jun. de 2018
Well, what is handles.Img? Does it exist? Did you assign it? did you remember to call guidata( hObject, handles ) after assigning it if it was in a different function?
Stelios Fanourakis
el 21 de Jun. de 2018
@Stelios Fanourakis: CData is a property of the image object (and other primitive objects), not the axes object. You will need the image handle, not the axes handle:
Stelios Fanourakis
el 21 de Jun. de 2018
"Yes, I assigned it as handles.Img = Img(:,:,S,:)"
That is not what I was taking about. An image is a primitive graphics object which is created by imshow, image, and other functions. When that image object has been created it has a handle. You can use its handle to access/change the graphics object (i.e. what is displayed).
What you showed is assigning a part of (an apparently) numeric array Img to the field Img of the structure handles. This is totally unrelated to any graphics objects, and unrelated to my comments so far.
If you want a graphics object you have to create it (either explicitly or implicitly using plot, imshow etc). Assigning part of an array to some variable does not create graphics objects.
Image Analyst
el 21 de Jun. de 2018
I don't use handles because I just deal with slow speed R&D images. I don't need the super high speed/real time imaging needed by writing directly to the CData property of the image object. Stelios, how fast do you need this to be? If it takes a tenth of a second to display an image is that too slow? Or do you need to update your screen at like 60 frames per second? If you're having a user click a slider, then you need to call imread() to get that image in from disk, that is going to be the bottle neck, rather than the display time. Is your user going to be clicking like 10 times per second? If so then you'll need to read all your images in beforehand into memory so there is no lag caused by imread(). Even then, there may be a limit to how fast the slider reacts to the clicks. It may not be able to call callbacks 10 times per second even if the callback was empty and did nothing - I don't know.
Why don't we just quit wasting time and have you attach your .m and .fig file so we can fix them?
Stelios Fanourakis
el 21 de Jun. de 2018
Image Analyst
el 22 de Jun. de 2018
Editada: Image Analyst
el 22 de Jun. de 2018
Attach staffs.png so I can see what size it is. Maybe you need to set the 'InitialMagnification' option in imshow().
Or zoom it. See attached demo.
Stelios Fanourakis
el 22 de Jun. de 2018
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!