You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How can I handle images?
3 views (last 30 days)
Show older comments
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?
Answers (1)
Image Analyst
on 20 Jun 2018
You can flip them easier without handles:
yourImage = fliplr(yourImage);
imshow(yourImage);
17 Comments
Stelios Fanourakis
on 20 Jun 2018
Sorry ImageAnalyst. I mean, I need handles to use them in a set() command in order to have them browsed using a slider
Image Analyst
on 20 Jun 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
on 21 Jun 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
on 21 Jun 2018
Stephen I believe it is the answer I am looking for. Can you please give me an example with set of how to control an image in an axes?
Like
set(handles.axes1, 'CData', Img(i))?
Is the above line correct?
Stelios Fanourakis
on 21 Jun 2018
I tried the above line but does not work
Stelios Fanourakis
on 21 Jun 2018
I get the error "There is no CData property on the Axes class."
Stelios Fanourakis
on 21 Jun 2018
If I put handles.Img instead I get the error that does not recognize Img
Stelios Fanourakis
on 21 Jun 2018
Yes, I assigned it as handles.Img = Img(:,:,S,:) where S is the frames index.
Stelios Fanourakis
on 21 Jun 2018
@Stephen Cobeldick. I know, but as I told you previously, i get the error of not Undefined Function Img
Stephen23
on 21 Jun 2018
Edited: Stephen23
on 21 Jun 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
on 21 Jun 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
on 21 Jun 2018
Thank you Image Analyst but everything is ok. I just need to place the logo. I use those lines for the logo
handles.axes7 = axes('Units','pixels','Position',[100 100 220 100]);
axes(handles.axes7)
matlabImage = imread('staffs.png');
imshow(matlabImage)
axis image
And I will either create a tiny logo or no logo at all, depending on the pixels values that I adjust no matter what.
I may do something wrong but I cannot find it. I want normal sized logo.
My project is working. I may need to update it or revise it in the upcoming months but I will definitely upload it to the community when is 100% finished
Image Analyst
on 22 Jun 2018
Edited: Image Analyst
on 22 Jun 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
on 22 Jun 2018
Thank you Image Analyst. I found the solution. I needed to set characters as unit.
See Also
Categories
Find more on Basic Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)