gui #4

  • Follow


hey!!

i hav created a simple gui comprising of a list box, a static text box and a command button...
the listbox comprises of a list of all the files....
when i double click on any image file it opens dat image and d name of the image file gets stored in a variable calld "filename"..
on d click of d button, the "filename" should be passed to another M file fr processing...which is not happenin....it is givin me 4 errors

on the call back of the button i hav written 

Adup=test_eucled(filename);

and in the test_eucled.m file i hav written 

function haar=test_eucled(filename) 

is sumthin wrong?? wat else shall i include??  how shall i pass d image fr processing frm d gui to another m file....

these are d list of errors im getting..........

undefined function or variable 'filename'.

Error in ==> test_lbox2>pushbutton1_Callback at 192
Adup=test_eucled(filename);

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

Error in ==> test_lbox2 at 43
    gui_mainfcn(gui_State, varargin{:});

Error in ==>
guidemfile>@(hObject,eventdata)test_lbox2('pushbutton1_Callback',hObject,eventdata,guidata(hObject))


??? Error while evaluating uicontrol Callback
0
Reply Hardik 4/13/2010 6:34:05 AM

Set a breakpoint on the line
Adup=test_eucled(filename);
and look at the variable filename.  Does it have a value?  Probably
not.  You probably forgot to assign anything to it.
0
Reply ImageAnalyst 4/13/2010 10:09:24 AM


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <da7497aa-a84a-45dd-a69e-69d235f9ef16@y14g2000yqm.googlegroups.com>...
> Set a breakpoint on the line
> Adup=test_eucled(filename);
> and look at the variable filename.  Does it have a value?  Probably
> not.  You probably forgot to assign anything to it.

hey image analyst!!

u were rite....d filename comprises d name of d file alog wid its extension eg: ELEPHANT.JPG

so i need to also pass d path of d image...which is contained in a variable called pwd
eg: D:\Image Processing

so now how do i pass d variable "filename" and "pwd"  to d file test_eucled.m?? 
pls can u write d statement along wid d syntax....as in what statement will cum in d GUI and wat will cum in d file test_eucled.m???
i tried doin d follow bt it din workout...

Adup=test_eucled(pwd,filename); %in d GUI

function haar=test_lbox2(pwd,filename)
fn=strcat(pwd,int2str('\'),filename);

i included "\" bcoz pwd comprises of only d:\foldername
so i need to put "\" after foldername and then d filename...

thanx image analyst fr helping me out!! 
0
Reply Hardik 4/13/2010 6:22:06 PM

You can use uigetfile() if you want to browse for a file
[baseFileName, folder] = uigetfile({'*.*'}, 'Select file');
if baseFileName ~= 0
	fullFileName = fullfile(folder, baseFileName);
end


or just type in the filename like this:
fullFileName = 'c:\images\myimageFile.jpg';

then call your function:
Adup=test_eucled(fullFileName);
0
Reply ImageAnalyst 4/13/2010 8:45:49 PM

By the way, you might want to use standard English.  It really helps
the non-English speaking users, and me as well - it takes about 10
times as long to read your message when you use cryptic non-words
like:
       d cum wat wid bt dn pls din u rite alog,
etc.
Why not make it easy for us to read your requests?
0
Reply ImageAnalyst 4/13/2010 8:50:39 PM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <7562ea92-34c1-457e-9cb4-face3b8a028d@c21g2000yqk.googlegroups.com>...
> By the way, you might want to use standard English.  It really helps
> the non-English speaking users, and me as well - it takes about 10
> times as long to read your message when you use cryptic non-words
> like:
>        d cum wat wid bt dn pls din u rite alog,
> etc.
> Why not make it easy for us to read your requests?


Thank You Sir!! The problem is solved!! Thank You !!!!

and I am extremely sorry for using slang words.....yes sir I will keep that in mind from next time!! 
0
Reply Hardik 4/14/2010 8:11:24 AM

hiii image analyst!!
i have created a simple GUI which comprises of loading of images. Thank You for helping me out with that.  My project supports only .JPG images.

What i want is that when the user selects .BMP or .tiff images or any other image format except JPEG (by selecting All Files from open dialog box) then i want a MSGBOX to prompt informing the users to upload only .JPG images. How shall i do that??? 

i tried writing the follow code but it gives me error for selecting each and every image

str='*.jpg';

if baseFileName == strcmp(str,baseFileName)
    global fullFileName
    if baseFileName ~= 0
    fullFileName = fullfile(folder, baseFileName);
    end
    disp(fullFileName);
    setappdata(hMainGui, 'fileName', fullFileName);
updateAxes

else
    msgbox('please enter images of .jpg format', 'error');
end

i just need help for showing the message box saying "please enter images of .jpg format"....Thank You again for helping me out with loading of image.....Now i just need to solve this problem regarding the Message Box...pls help...
0
Reply Hardik 5/5/2010 9:49:03 PM

On May 5, 2:49=A0pm, "Hardik " <hardik...@hotmail.com> wrote:
> hiii image analyst!!
> i have created a simple GUI which comprises of loading of images. Thank Y=
ou for helping me out with that. =A0My project supports only .JPG images.
>
> What i want is that when the user selects .BMP or .tiff images or any oth=
er image format except JPEG (by selecting All Files from open dialog box) t=
hen i want a MSGBOX to prompt informing the users to upload only .JPG image=
s. How shall i do that???
>
> i tried writing the follow code but it gives me error for selecting each =
and every image
>
> str=3D'*.jpg';
>
> if baseFileName =3D=3D strcmp(str,baseFileName)
> =A0 =A0 global fullFileName
> =A0 =A0 if baseFileName ~=3D 0
> =A0 =A0 fullFileName =3D fullfile(folder, baseFileName);
> =A0 =A0 end
> =A0 =A0 disp(fullFileName);
> =A0 =A0 setappdata(hMainGui, 'fileName', fullFileName);
> updateAxes
>
> else
> =A0 =A0 msgbox('please enter images of .jpg format', 'error');
> end
>
> i just need help for showing the message box saying "please enter images =
of .jpg format"....Thank You again for helping me out with loading of image=
......Now i just need to solve this problem regarding the Message Box...pls =
help...

How about:

str =3D {'.jpg','.jpeg'};
[ext ext ext] =3D fileparts(baseFileName);
if max(strcmp(str,ext))
    global fullFileName
    if baseFileName ~=3D 0
    fullFileName =3D fullfile(folder, baseFileName);
    end
    disp(fullFileName);
    setappdata(hMainGui, 'fileName', fullFileName);
updateAxes

else
    msgbox('please enter images of .jpg format', 'error');
end


Does this work for you?

-Nathan
0
Reply Nathan 5/5/2010 10:11:16 PM

Nathan <ngreco32@gmail.com> wrote in message <2d729990-3274-4267-ba19-53933f57da4e@s29g2000yqd.googlegroups.com>...
> On May 5, 2:49 pm, "Hardik " <hardik...@hotmail.com> wrote:
> > hiii image analyst!!
> > i have created a simple GUI which comprises of loading of images. Thank You for helping me out with that.  My project supports only .JPG images.
> >
> > What i want is that when the user selects .BMP or .tiff images or any other image format except JPEG (by selecting All Files from open dialog box) then i want a MSGBOX to prompt informing the users to upload only .JPG images. How shall i do that???
> >
> > i tried writing the follow code but it gives me error for selecting each and every image
> >
> > str='*.jpg';
> >
> > if baseFileName == strcmp(str,baseFileName)
> >     global fullFileName
> >     if baseFileName ~= 0
> >     fullFileName = fullfile(folder, baseFileName);
> >     end
> >     disp(fullFileName);
> >     setappdata(hMainGui, 'fileName', fullFileName);
> > updateAxes
> >
> > else
> >     msgbox('please enter images of .jpg format', 'error');
> > end
> >
> > i just need help for showing the message box saying "please enter images of .jpg format"....Thank You again for helping me out with loading of image.....Now i just need to solve this problem regarding the Message Box...pls help...
> 
> How about:
> 
> str = {'.jpg','.jpeg'};
> [ext ext ext] = fileparts(baseFileName);
> if max(strcmp(str,ext))
>     global fullFileName
>     if baseFileName ~= 0
>     fullFileName = fullfile(folder, baseFileName);
>     end
>     disp(fullFileName);
>     setappdata(hMainGui, 'fileName', fullFileName);
> updateAxes
> 
> else
>     msgbox('please enter images of .jpg format', 'error');
> end
> 
> 
> Does this work for you?
> 
> -Nathan

hey Nathan!!! 
yes that worked for me!!! thank you so much !!!!

Thank You Sir!!!
0
Reply Hardik 5/5/2010 10:22:05 PM

"Hardik " <hardik_88@hotmail.com> wrote in message <hrsr2d$sh1$1@fred.mathworks.com>...
> Nathan <ngreco32@gmail.com> wrote in message <2d729990-3274-4267-ba19-53933f57da4e@s29g2000yqd.googlegroups.com>...
> > On May 5, 2:49 pm, "Hardik " <hardik...@hotmail.com> wrote:
> > > hiii image analyst!!
> > > i have created a simple GUI which comprises of loading of images. Thank You for helping me out with that.  My project supports only .JPG images.
> > >
> > > What i want is that when the user selects .BMP or .tiff images or any other image format except JPEG (by selecting All Files from open dialog box) then i want a MSGBOX to prompt informing the users to upload only .JPG images. How shall i do that???
> > >
> > > i tried writing the follow code but it gives me error for selecting each and every image
> > >
> > > str='*.jpg';
> > >
> > > if baseFileName == strcmp(str,baseFileName)
> > >     global fullFileName
> > >     if baseFileName ~= 0
> > >     fullFileName = fullfile(folder, baseFileName);
> > >     end
> > >     disp(fullFileName);
> > >     setappdata(hMainGui, 'fileName', fullFileName);
> > > updateAxes
> > >
> > > else
> > >     msgbox('please enter images of .jpg format', 'error');
> > > end
> > >
> > > i just need help for showing the message box saying "please enter images of .jpg format"....Thank You again for helping me out with loading of image.....Now i just need to solve this problem regarding the Message Box...pls help...
> > 
> > How about:
> > 
> > str = {'.jpg','.jpeg'};
> > [ext ext ext] = fileparts(baseFileName);
> > if max(strcmp(str,ext))
> >     global fullFileName
> >     if baseFileName ~= 0
> >     fullFileName = fullfile(folder, baseFileName);
> >     end
> >     disp(fullFileName);
> >     setappdata(hMainGui, 'fileName', fullFileName);
> > updateAxes
> > 
> > else
> >     msgbox('please enter images of .jpg format', 'error');
> > end
> > 
> > 
> > Does this work for you?
> > 
> > -Nathan
> 
> hey Nathan!!! 
> yes that worked for me!!! thank you so much !!!!
> 
> Thank You Sir!!!

hi Nathan...
i wanted to ask another question...When the Axes Box does not contain any image and when user clicks on the Push button then an error should come or another MSGBOX should be displayed sayin "Pllease upload an image" What shall we do in dis case???
0
Reply Hardik 5/5/2010 10:42:04 PM

Well I guess you'd call warndlg().
0
Reply ImageAnalyst 5/6/2010 2:11:34 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <fcee5eba-aa0f-4534-b7c9-0537addf289e@o12g2000vba.googlegroups.com>...
> Well I guess you'd call warndlg().


alrite....but wat condition shall i specify in order to check whether the axes box is empty??? 
0
Reply Hardik 5/6/2010 9:05:05 AM

11 Replies
163 Views

(page loaded in 0.14 seconds)


Reply: