Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I display image in a specified panel in GUI?

364 views
Skip to first unread message

YIMING

unread,
Jan 2, 2011, 12:32:04 AM1/2/11
to
Suppose I created a panel in my Matlab GUI, and wish to display a image there. How do I achieve this? B.t.w, I need to resize the image so that it will just fit the panel size.

ImageAnalyst

unread,
Jan 2, 2011, 12:49:40 AM1/2/11
to
On Jan 2, 12:32 am, "YIMING " <niuym8...@gmail.com> wrote:
> Suppose I created a panel in my Matlab GUI, and wish to display a image there. How do I achieve this? B.t.w, I need to resize the image so that it will just fit the panel size.
------------------------------------------------------------------------
Put an "axes" control on your figure - not a panel. Then do code like
this when you want to display something in it

axes(handles.axesImage);
imshow(imageArray, []);

You can also use image or imagesc if you don't have the Image
Processing Toolbox.

Walter Roberson

unread,
Jan 2, 2011, 4:37:39 AM1/2/11
to

panhandle = uipanel(...);
panax = axes('Units','normal', 'Position', [0 0 1 1], 'Parent', panhandle);
imhandle = imshow(panax, ImageToShow);

YIMING

unread,
Jan 2, 2011, 4:55:05 AM1/2/11
to
ImageAnalyst <imagea...@mailinator.com> wrote in message <dfcea983-9732-49c3...@s4g2000yql.googlegroups.com>...

Hey man, thanks for your reply.

But I just wonder why is it necessary to use 'axes' or image processing toolbox. I use want to show an image in a certain place with a certain scale.

Yumnam Kirani

unread,
Jan 2, 2011, 5:22:04 AM1/2/11
to
The reason is simple you cannot do it without using them. Am I wrong?
Yumnam Kirani Singh
Tronglaobi Awang Leikai

"YIMING" wrote in message <ifpi1p$nbv$1...@fred.mathworks.com>...

YIMING

unread,
Jan 2, 2011, 7:06:04 AM1/2/11
to
I'm not clear with your suggestions below,

axes(handles.axesImage);
imshow(imageArray, []);

As I created a GUI for displaying images, what do you mean by "put an 'axes' control on the figure"? The scenario is actually, I have a 'browser' button on my UI, by clicking with I could select an image file, and I wish to render it on a specified location of my GUI with a certain scale.

Would you please elaborate your method? Thank you very much for this.

"Yumnam Kirani" <kirani...@gmail.com> wrote in message <ifpjkc$4sv$1...@fred.mathworks.com>...

Bruno Luong

unread,
Jan 2, 2011, 8:14:06 AM1/2/11
to
"YIMING" wrote in message <ifppnc$3lp$1...@fred.mathworks.com>...

> I'm not clear with your suggestions below,
>
> axes(handles.axesImage);
> imshow(imageArray, []);
>
> As I created a GUI for displaying images, what do you mean by "put an 'axes' control on the figure"? The scenario is actually, I have a 'browser' button on my UI, by clicking with I could select an image file, and I wish to render it on a specified location of my GUI with a certain scale.
>
> Would you please elaborate your method? Thank you very much for this.

All graphic plots (line, image) have to be plotted on the so-called AXES in Matlab. So you need to create an AXES either with AXES command or if you are using GUIDE add an AXES object.

To learn more, read
help AXES
help GCA

Replace imshow() (image processing toolbox required) with image() of imagesc() command.

Bruno

0 new messages