If I got two axes, if I want to one of the axes to display
an img, how can I write it in code, pls,
many thx...
And also when I use the filesparts function, when I press
the cancelbutton
I get this error~~
?? Error using ==> fileparts at 17
Input must be a row vector of characters.
Error in ==> appl>browse_Callback at 143
[pathstr,name,ext,versn] = fileparts(get
(handles.inputimg_ed,'string'));
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> appl at 42
gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback
Can you pls help me to solve it?
Here's my code
function browse_Callback(hObject, eventdata, handles)
% hObject handle to browse (see GCBO)
% eventdata reserved - to be defined in a future version
of MATLAB
% handles structure with handles and user data (see
GUIDATA)
[pathstr,name,ext,versn] = fileparts(get
(handles.inputimg_ed,'string'));
if ~isempty(pathstr),
pathstr = [pathstr '\'];
end
try
[file,path] = uigetfile([pathstr '*.jpg'],'Select an
image');
set(handles.inputimg_ed,'string',[path file]);
info = imfinfo([path file]);
set(handles.width_ed,'string',info.Width);
set(handles.height_ed,'string',info.Height);
imshow([path file]);
catch
end
"Phil Au" <philipawt@gmail.com> wrote in message
<fpaofr$ru7$1@fred.mathworks.com>...
> Hi All,
>
> I got an question about my GUI matlab,
>
> If I got two axes, if I want to one of the axes to display
> an img, how can I write it in code, pls,
>
> many thx...
>
Answer to your first question
axes(handles.axes1); %assuming axes1 is the name of the
first %axes
imshow(yourimage);
In article <fpaofr$ru7$1@fred.mathworks.com>,
Phil Au <philipawt@gmail.com> wrote:
>And also when I use the filesparts function, when I press
>the cancelbutton
>I get this error~~
>?? Error using ==> fileparts at 17
>Input must be a row vector of characters.
>Here's my code
>
> [file,path] = uigetfile([pathstr '*.jpg'],'Select an image');
What is the documented output result when you cancel a uigetfile
dialog?
--
"Why does he stagger his mind with the mathematics of the sky?
Once the question mark has arisen in the human brain the answer must
be found, if it takes a hundred years. A thousand years."
-- Walter Reisch
Thx for your reply first.
It was used in the Browse button, whem i press the button,
it was supposed to select an image file and if I selected a
file, it will display the path of the file in an edit box,
and diplay the details of the img and the actual img.
But I i press the cancel button, the edit box which used to
display the path of the file is disappeareed and when I
press the button again, I got this error..
Thanks for your time and help
>
> >And also when I use the filesparts function, when I
press
> >the cancelbutton
>
> >I get this error~~
>
> >?? Error using ==> fileparts at 17
> >Input must be a row vector of characters.
>
> >Here's my code
> >
>
> > [file,path] = uigetfile([pathstr '*.jpg'],'Select an
image');
>
> What is the documented output result when you cancel a
uigetfile
> dialog?
> --
> "Why does he stagger his mind with the mathematics of
the sky?
> Once the question mark has arisen in the human brain
the answer must
> be found, if it takes a hundred years. A thousand
years."
> -- Walter
Reisch
In article <fpbnqu$2in$1@fred.mathworks.com>,
Phil Au <philipawt@gmail.com> wrote:
>Thx for your reply first.
>It was used in the Browse button, whem i press the button,
>it was supposed to select an image file and if I selected a
>file, it will display the path of the file in an edit box,
>and diplay the details of the img and the actual img.
>But I i press the cancel button, the edit box which used to
>display the path of the file is disappeareed and when I
>press the button again, I got this error..
You use fileparts -first- and then you use uigetfile. So any
problem with uigetfile will not be reflected until the -next-
time you call the function.
>> > [file,path] = uigetfile([pathstr '*.jpg'],'Select an
>image');
>> What is the documented output result when you cancel a
>uigetfile
>> dialog?
To answer my hint to you myself: when the user cancels
uigetfile, the return value is the -number- 0, not
a string. You then store that 0 in a handle, and the next
call around, you pull the numeric 0 out and try to use it
in fileparts, which promptly complains because you have not
passed fileparts a string.
--
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth
On Feb 18, 6:29=A0am, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:
> In article <fpbnqu$2i...@fred.mathworks.com>,
>
> Phil Au <philip...@gmail.com> wrote:
> >Thx for your reply first.
> >It was used in the Browse button, whem i press the button,
> >it was supposed to select an image file and if I selected a
> >file, it will display the path of the file in an edit box,
> >and diplay the details of the img and the actual img.
> >But I i press the cancel button, the edit box which used to
> >display the path of the file is disappeareed and when I
> >press the button again, I got this error..
>
> You use fileparts -first- and then you use uigetfile. So any
> problem with uigetfile will not be reflected until the -next-
> time you call the function.
>
> >> > =A0 =A0[file,path] =3D uigetfile([pathstr '*.jpg'],'Select an
> >image');
> >> What is the documented output result when you cancel a
> >uigetfile
> >> dialog?
>
> To answer my hint to you myself: when the user cancels
> uigetfile, the return value is the -number- 0, not
> a string. You then store that 0 in a handle, and the next
> call around, you pull the numeric 0 out and try to use it
> in fileparts, which promptly complains because you have not
> passed fileparts a string.
> --
> =A0 =A0"Beware of bugs in the above code; I have only proved it correct,
> =A0 =A0not tried it." =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0-- Donald Knuth
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
It's issues like this that make me wish MATLAB were a strongly typed
language like most other programming languages, where you were
required to declare variables of a certain type before you could use
them, and they maintained that type every time you used them. I know
you give up some flexibility in being able to write fast, sloppy code
but other languages agree that that "advantage" does not outweigh the
potential problems it causes.
Regards,
ImageAnalyst
Hi Walter,
Thx again for the reply, I edited the code as below, now i
dont have the error, but i can't use the browse button if
I press the cancel, Do you know how can I still use the
browse button even I press the cancel button
try
[pathstr,name,ext,versn] = fileparts(get
(handles.inputimg_ed,'string'));
if ~isempty(pathstr),
pathstr = [pathstr '\'];
else
[pathstr,name,ext,versn] = fileparts(get
(handles.inputimg_ed,'string'));
end
[file,path] = uigetfile([pathstr '*.jpg'],'Select an
image');
if isequal(pathstr,0)
set(handles.inputimg_ed,'string','cancelled');
else
set(handles.inputimg_ed,'string',[path file]);
end
info = imfinfo([path file]);
set(handles.width_ed,'string',info.Width);
set(handles.height_ed,'string',info.Height);
imshow([path file]);
catch
btw, do you know why I got an Warning: Single line Edit
Controls can not have multi-line text.
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
message <fpbq6o$4e2$1@canopus.cc.umanitoba.ca>...
> In article <fpbnqu$2in$1@fred.mathworks.com>,
> Phil Au <philipawt@gmail.com> wrote:
>
> >Thx for your reply first.
> >It was used in the Browse button, whem i press the
button,
> >it was supposed to select an image file and if I
selected a
> >file, it will display the path of the file in an edit
box,
> >and diplay the details of the img and the actual img.
>
> >But I i press the cancel button, the edit box which used
to
> >display the path of the file is disappeareed and when I
> >press the button again, I got this error..
>
> You use fileparts -first- and then you use uigetfile. So
any
> problem with uigetfile will not be reflected until the -
next-
> time you call the function.
>
>
> >> > [file,path] = uigetfile([pathstr '*.jpg'],'Select
an
> >image');
>
> >> What is the documented output result when you cancel a
> >uigetfile
> >> dialog?
>
> To answer my hint to you myself: when the user cancels
> uigetfile, the return value is the -number- 0, not
> a string. You then store that 0 in a handle, and the next
> call around, you pull the numeric 0 out and try to use it
> in fileparts, which promptly complains because you have
not
> passed fileparts a string.
> --
> "Beware of bugs in the above code; I have only proved
it correct,
> not tried it." --
Donald Knuth
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
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.
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.