Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to show a image in certian axes of GUI

Subject: How to show a image in certian axes of GUI

From: Rikcuo Akira

Date: 9 Nov, 2007 05:41:10

Message: 1 of 10

How to show a image in certian axes of GUI?
imshow function does not have the handle of axes.

function drawbutton_Callback(hObject, eventdata, handles)

[FileName,PathName, FilterIndex] = uigetfile
('*.bmp;*.jpg','Select the Image-file');
FullFileName=sprintf('%s%s',PathName,FileName)
filename=FullFileName;
f=imread(filename);
imshow(f);

Subject: How to show a image in certian axes of GUI

From: JWagberg

Date: 9 Nov, 2007 07:41:29

Message: 2 of 10

On Nov 9, 6:41 am, "Rikcuo Akira" <rikcuo.ak...@msa.hinet.net> wrote:
> How to show a image in certian axes of GUI?
> imshow function does not have the handle of axes.

It does, even if it's not up front.

imshow(..., 'Parent', hax);

HTH,
jewa & wagberg , net (Replace the obvious)

Subject: How to show a image in certian axes of GUI

From: Rikcuo Akira

Date: 9 Nov, 2007 07:58:27

Message: 3 of 10

function drawbutton_Callback(hObject, eventdata, handles)

[FileName,PathName, FilterIndex] = uigetfile
('*.bmp;*.jpg','Select the Image-file');
FullFileName=sprintf('%s%s',PathName,FileName)
filename=FullFileName;
f=imread(filename);
imshow(f, 'Parent', handles.axes1);%modified

%The line I had modified above does not work as I hope,
becuase it appeared many errors as below:

??? Error using ==>
imuitools\private\imageDisplayParseInputs
Invalid input arguments.

Error in ==> imshow at 151
  [cdata, cdatamapping, clim, map, xdata, ydata, ...

Error in ==> AkGUI2>drawbutton_Callback at 86
imshow(f, 'Parent', handles.axes1);

Error in ==> gui_mainfcn at 75
        feval(varargin{:});

Error in ==> AkGUI2 at 42
    gui_mainfcn(gui_State, varargin{:});

%Is the "input arguments" not right?

Subject: How to show a image in certian axes of GUI

From: Rikcuo Akira

Date: 9 Nov, 2007 08:26:20

Message: 4 of 10

I seem to find the answer:

axes(handles.axes3);
imshow(f);

reference:
http://www.mathworks.com/matlabcentral/newsreader/view_thre
ad/157652#396636

Subject: How to show a image in certian axes of GUI

From: JWagberg

Date: 12 Nov, 2007 13:38:38

Message: 5 of 10

On Nov 9, 8:58 am, "Rikcuo Akira" <rikcuo.ak...@msa.hinet.net> wrote:
> function drawbutton_Callback(hObject, eventdata, handles)
> ...
> f=imread(filename);
> imshow(f, 'Parent', handles.axes1);%modified
>
> %Is the "input arguments" not right?

The above should work, provided that handles.axes1 is indeed a valid
handle and your Matlab version is reasonably new. Can't remember right
now when the 'Parent' argument was introduced.

jewa & wagberg , net (Replace the obvious)

Subject: How to show a image in certian axes of GUI

From: Rikcuo Akira

Date: 12 Nov, 2007 14:03:25

Message: 6 of 10

I had tried the line again.
> > imshow(f, 'Parent', handles.axes1);%modified
But I still failed, because it appears some errors as
below:

??? Error using ==>
imuitools\private\imageDisplayParseInputs
Invalid input arguments.

Error in ==> imshow at 151
  [cdata, cdatamapping, clim, map, xdata, ydata, ...

Error in ==> AkGUI1>LoadImageButton_Callback at 98
imshow(fimage, 'Parent', handles.axes1);%

Error in ==> gui_mainfcn at 75
        feval(varargin{:});

Error in ==> AkGUI1 at 42
    gui_mainfcn(gui_State, varargin{:});

??? Error using ==> AkGUI1('LoadImageButton_Callback',gcbo,
[],guidata(gcbo))
Error using ==> imuitools\private\imageDisplayParseInputs
Invalid input arguments.

??? Error while evaluating uicontrol Callback

Subject: How to show a image in certian axes of GUI

From: Rikcuo Akira

Date: 12 Nov, 2007 14:03:35

Message: 7 of 10

I had tried the line again.
> > imshow(f, 'Parent', handles.axes1);%modified
But I still failed, because it appears some errors as
below:

??? Error using ==>
imuitools\private\imageDisplayParseInputs
Invalid input arguments.

Error in ==> imshow at 151
  [cdata, cdatamapping, clim, map, xdata, ydata, ...

Error in ==> AkGUI1>LoadImageButton_Callback at 98
imshow(fimage, 'Parent', handles.axes1);%

Error in ==> gui_mainfcn at 75
        feval(varargin{:});

Error in ==> AkGUI1 at 42
    gui_mainfcn(gui_State, varargin{:});

??? Error using ==> AkGUI1('LoadImageButton_Callback',gcbo,
[],guidata(gcbo))
Error using ==> imuitools\private\imageDisplayParseInputs
Invalid input arguments.

??? Error while evaluating uicontrol Callback

Subject: How to show a image in certian axes of GUI

From: Rikcuo Akira

Date: 12 Nov, 2007 14:07:23

Message: 8 of 10

>> imshow(f, 'Parent', handles.axes1);%modified>
The line will appear some errors when I tried again.
Did you ever try it! My Matlab is R2006a and you?

Subject: How to show a image in certian axes of GUI

From: JWagberg

Date: 12 Nov, 2007 23:06:14

Message: 9 of 10

On Nov 12, 3:07 pm, "Rikcuo Akira" <rikcuo.ak...@msa.hinet.net> wrote:
> >> imshow(f, 'Parent', handles.axes1);%modified>
>
> The line will appear some errors when I tried again.
> Did you ever try it! My Matlab is R2006a and you?

This works for me with Matlab 2007b:

im=imread('peppers.png');
h=subplot(121);
subplot(122);
imshow(im, 'Parent', h);

HTH,
jewa & wagberg , net (Replace the obvious)

Subject: How to show a image in certian axes of GUI

From: Senzota

Date: 5 Apr, 2013 19:42:06

Message: 10 of 10

me two I tried the l following code its work well with matlab 2012b
>> imshow(f, 'Parent', handles.axes1);%modified>

 JWagberg <jerwag@gmail.com> wrote in message <1194908774.569239.246580@22g2000hsm.googlegroups.com>...
> On Nov 12, 3:07 pm, "Rikcuo Akira" <rikcuo.ak...@msa.hinet.net> wrote:
> > >> imshow(f, 'Parent', handles.axes1);%modified>
> >
> > The line will appear some errors when I tried again.
> > Did you ever try it! My Matlab is R2006a and you?
>
> This works for me with Matlab 2007b:
>
> im=imread('peppers.png');
> h=subplot(121);
> subplot(122);
> imshow(im, 'Parent', h);
>
> HTH,
> jewa & wagberg , net (Replace the obvious)
>

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us