I am making a GUI in which i want to display two images at
the sides.I saw the video on Matlabcental about setting
background images using imshow() in the CreateFn of the axes
created and tried it out.
The problem i am facing is that when i close Matlab and run
the GUI again or run it on a different PC the axes 'tag'
field becomes empty and the visibility is hence 'off'. Every
time i have to rename the axes and go to the CreateFn of the
axes.
"Vaibhav Bedia" <vaibhav.bedia@gmail.com> wrote in message
<fmhg3f$e5q$1@fred.mathworks.com>...
> I am making a GUI in which i want to display two images at
> the sides.I saw the video on Matlabcental about setting
> background images using imshow() in the CreateFn of the axes
> created and tried it out.
>
> The problem i am facing is that when i close Matlab and run
> the GUI again or run it on a different PC the axes 'tag'
> field becomes empty and the visibility is hence 'off'. Every
> time i have to rename the axes and go to the CreateFn of the
> axes.
>
> I am using R2007b.
>
> How can i solve this isssue?
Hello
If you have two images displayed separatly then you will
require to define 2 axes on the gui window. Drop down the
axes from the toolbox using guide into your fig.
Assuming, axes1 and axes2 are the variables.
You can then issues
axes(handles.axes1); % this is used to set focus on the axes
%currently in use
imshow('firstimage');
oi!
i have similar problem ->
i have 2 axes (axes1, axes2) on my figure in gui, when i
set axes1 active [axes(handles.axes1)] and i check for tag
property i get apropriate tag -> 'axes1' in next line i'm
showing pic with [imshow(pic)] 3rd line is chcecking again
for the tag property and BAM -> '' EMPTY
i even tried to name it again after imshowing but it
appears that somehow axes1 duplicates becouse finding all
axes types results in showing 3 axes instead of 2:
axes =
'axes1'
''
'axes2'
if u have any ideas how to overcome it - please help
"Szymon Lipiec" <szymon.lipiec@gmail.com> wrote in message
<fmi9bh$s3j$1@fred.mathworks.com>...
> oi!
> i have similar problem ->
> i have 2 axes (axes1, axes2) on my figure in gui, when i
> set axes1 active [axes(handles.axes1)] and i check for
tag
> property i get apropriate tag -> 'axes1' in next line i'm
> showing pic with [imshow(pic)] 3rd line is chcecking
again
> for the tag property and BAM -> '' EMPTY
> i even tried to name it again after imshowing but it
> appears that somehow axes1 duplicates becouse finding all
> axes types results in showing 3 axes instead of 2:
>
> axes =
> 'axes1'
> ''
> 'axes2'
>
> if u have any ideas how to overcome it - please help
When you create the axes, the NextPlot property of this
axes to "add" value
I tried putting what Anh said in the CreateFn of the axes
but it didnt work.Was that where i was supposed to put it?
But i got it working in a diff way.Added the following in
the OpeningFn of the GUI.
%load the background image into Matlab
%if image is not in the same directory as the GUI files,
you must use the
%full path name of the image file
Image1 = importdata('image1.jpg');
Image2 = importdata('image2.jpg');
%select the axes
axes(handles.axes13);
%place image onto the axes
image(Image1);
%remove the axis tick marks
axis off
%select the axes
axes(handles.axes12);
%place image onto the axes
image(Image2);
%remove the axis tick marks
axis off
"Anh Huy Phan" <phananhhuy@mathworks.com> wrote in message
<fmieie$fbq$1@fred.mathworks.com>...
> "Szymon Lipiec" <szymon.lipiec@gmail.com> wrote in
message
> <fmi9bh$s3j$1@fred.mathworks.com>...
> > oi!
> > i have similar problem ->
> > i have 2 axes (axes1, axes2) on my figure in gui, when
i
> > set axes1 active [axes(handles.axes1)] and i check for
> tag
> > property i get apropriate tag -> 'axes1' in next line
i'm
> > showing pic with [imshow(pic)] 3rd line is chcecking
> again
> > for the tag property and BAM -> '' EMPTY
> > i even tried to name it again after imshowing but it
> > appears that somehow axes1 duplicates becouse finding
all
> > axes types results in showing 3 axes instead of 2:
> >
> > axes =
> > 'axes1'
> > ''
> > 'axes2'
> >
> > if u have any ideas how to overcome it - please help
>
> When you create the axes, the NextPlot property of this
> axes to "add" value
>
> figure
>
> set(gca,'NextPlot','add')
> set(gca,'Tag','myaxes')
> ...
> ...
>
> Anh Huy Phan
> RIKEN - BSI
"Vaibhav Bedia" <vaibhav.bedia@gmail.com> wrote in message
<fmim81$d4r$1@fred.mathworks.com>...
> I tried putting what Anh said in the CreateFn of the axes
> but it didnt work.Was that where i was supposed to put it?
>
> But i got it working in a diff way.Added the following in
> the OpeningFn of the GUI.
>
> %load the background image into Matlab
> %if image is not in the same directory as the GUI files,
> you must use the
> %full path name of the image file
> Image1 = importdata('image1.jpg');
> Image2 = importdata('image2.jpg');
> %select the axes
> axes(handles.axes13);
> %place image onto the axes
> image(Image1);
> %remove the axis tick marks
> axis off
>
> %select the axes
> axes(handles.axes12);
> %place image onto the axes
> image(Image2);
> %remove the axis tick marks
> axis off
>
> % Update handles structure
> guidata(hObject, handles);
>
> Maybe this will solve Szymon's problem also.
>
> "Anh Huy Phan" <phananhhuy@mathworks.com> wrote in
message
> <fmieie$fbq$1@fred.mathworks.com>...
> > "Szymon Lipiec" <szymon.lipiec@gmail.com> wrote in
> message
> > <fmi9bh$s3j$1@fred.mathworks.com>...
> > > oi!
> > > i have similar problem ->
> > > i have 2 axes (axes1, axes2) on my figure in gui,
when
> i
> > > set axes1 active [axes(handles.axes1)] and i check
for
> > tag
> > > property i get apropriate tag -> 'axes1' in next line
> i'm
> > > showing pic with [imshow(pic)] 3rd line is chcecking
> > again
> > > for the tag property and BAM -> '' EMPTY
> > > i even tried to name it again after imshowing but it
> > > appears that somehow axes1 duplicates becouse finding
> all
> > > axes types results in showing 3 axes instead of 2:
> > >
> > > axes =
> > > 'axes1'
> > > ''
> > > 'axes2'
> > >
> > > if u have any ideas how to overcome it - please help
> >
> > When you create the axes, the NextPlot property of this
> > axes to "add" value
> >
> > figure
> >
> > set(gca,'NextPlot','add')
> > set(gca,'Tag','myaxes')
> > ...
> > ...
> >
> > Anh Huy Phan
> > RIKEN - BSI
>
I am using GUI from matlab 2008a. In my program I have much
axes, and a specific one. On that specific axes I need to
draw a horizontal line on the place where user clicks (I'm
using imshow function). The size of the image that I need to
draw is modified so that it can fit in the axes perfectly
(axes and image are the same size).
Besides that (besides drawing a horizontal line on the place
where user clicks), I need to update handles structure with
info about mouse pozition. So I figured the best way to do
this is if I use ButtonDownFcn from the axes.
I already turned image's HitTest to off. and that works.
Then I heard that axes replaces all properties when you draw
new image. So I set NextPlot to add.
And ButtonDownFcn worked. Now when I click on the picture,
axesTrenutniFrame_ButtonDownFcn is called. But one new
problem occured.
Now, Image that I'm drawing won't fit to the axes perfectly.
My axes is (15x800), and the imagethat I need to draw is
(15x800x3), but now image is rescaled.
Here is part of my code. It is from GUI opening function. It
is a picture with 9 horizontal lines and one red line at
101.-103. pixel
slika = ones (15, 800, 3) * 255;
a = floor(linspace(1, 800, 9));
slika (:, a, :) = 0;
slika (:, 101:103, 2:3) = 0;
slika = uint8(slika);
axes(handles.axesTrenutniFrame);
g = imshow(slika);
set(g,'HitTest','off');
I also tried to set NextPlot to other values. Everithing but
'Replace' rescales my image. Can you help me so that I can
get image that perfectly fits to the axes, and that I get
axesTrenutniFrame_ButtonDownFcn called when I click on the image
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.