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:
Store the path of images that i'm loading in axes1

Subject: Store the path of images that i'm loading in axes1

From: Sprinceana

Date: 14 Mar, 2009 15:17:01

Message: 1 of 6

Hi everybody! I am using guide tool for creating GUI applications in Matlab.

On my file test.fig I have the following components:

-1button pushbutton1 to load my image in axes1 component
-1 listbox listbox1 where I want to store each path of every image that I store in axes1 component.


I attach hear the callback for pushbutton1 function:


[filename,pathname] = uigetfile({'*.jpg';'*.png';'*.bmp'}); %selection on my file to apply an open dialog using uigetfile function


if ~ischar(filename)

%on cancel press store me this message in an error dialog
    errordlg('Eroare!','Nici un fisier selectat!');
   return;
 end

img = imread(fullfile(pathname,filename)); %reading the image from path
imshow(img); %displaying image in axes1

img=imread(fullfile(pathname,filename));
imshow(var,'parent',handles.axes1);

str = get(handles.listbox1,'string');
str = cellstr(str);
str{end+1} = fullfile(pathname,filename);
set(handles.listbox1,'string',str); %store in listbox1 each path for each file that i store in axes1

Subject: Store the path of images that i'm loading in axes1

From: Image Analyst

Date: 14 Mar, 2009 21:22:01

Message: 2 of 6

Sprinceana :
OK. But do you have a question? Well I have one. Why are you storing the full filename in the listbox? Why not just store it in a static text. A listbox is supposed to take some action when you click on it. What are you going to do - it's already displayed?

Subject: Store the path of images that i'm loading in axes1

From: Sprinceana

Date: 15 Mar, 2009 14:50:02

Message: 3 of 6

"Image Analyst" <imageanalyst@mailinator.com> wrote in message <gph75p$5ah$1@fred.mathworks.com>...
> Sprinceana :
> OK. But do you have a question? Well I have one. Why are you storing the full filename in the listbox? Why not just store it in a static text. A listbox is supposed to take some action when you click on it. What are you going to do - it's already displayed?


So instead of listbox I put on form a static text component and I modify the code like that:

[filename,pathname] = uigetfile({'*.jpg';'*.png';'*.bmp'}); %selection on my file to apply an open dialog using uigetfile function


if ~ischar(filename)

%on cancel press store me this message in an error dialog
    errordlg('Eroare!','Nici un fisier selectat!');
   return;
 end

img = imread(fullfile(pathname,filename)); %reading the image from path
imshow(img); %displaying image in axes1

img=imread(fullfile(pathname,filename));
imshow(var,'parent',handles.axes1);

str = get(handles.listbox1,'string');
str = cellstr(str);
str{end+1} = fullfile(pathname,filename);
set(handles.text1,'string',str); %store in listbox1 each path for each file that i store in axes1 %text1 is the tag property of component static text


I wait a response if it's ok!

Subject: Store the path of images that i'm loading in axes1

From: Sprinceana

Date: 15 Mar, 2009 15:08:01

Message: 4 of 6

On my form I have the following components I uploaded the image here:

http://img24.imageshack.us/img24/4059/forminmatlab.png

Subject: Store the path of images that i'm loading in axes1

From: ImageAnalyst

Date: 15 Mar, 2009 21:03:14

Message: 5 of 6

On Mar 15, 11:08=A0am, "Sprinceana " <mihai...@yahoo.com> wrote:
> On my form I have the following components I uploaded the image here:
>
> http://img24.imageshack.us/img24/4059/forminmatlab.png
---------------------------------------------------------------------------=
-------------------------
Sprinceana :
I didn't see a listbox there. But anyway, if you want to store a
single filename, then putting it into a static text is best. If you
want to keep track and store ALL of the different filenames then you
can either put them all in an Edit Text or in different entries of a
listbox. Either will allow you to scroll through the list. The
listbox will let you take an action when you click on the item but an
edit text will not. It depends if you expect your users to click on a
filename that they've looked at before and if want to do anything if
they do click on it.
Regards,
ImageAnalyst

Subject: Store the path of images that i'm loading in axes1

From: Sprinceana

Date: 31 Mar, 2009 19:47:01

Message: 6 of 6

"Sprinceana " <mihaispr@yahoo.com> wrote in message <gpghpd$5ie$1@fred.mathworks.com>...
> Hi everybody! I am using guide tool for creating GUI applications in Matlab.
>
> On my file test.fig I have the following components:
>
> -1button pushbutton1 to load my image in axes1 component
> -1 listbox listbox1 where I want to store each path of every image that I store in axes1 component.
>
>
> I attach hear the callback for pushbutton1 function:
>
>
> [filename,pathname] = uigetfile({'*.jpg';'*.png';'*.bmp'}); %selection on my file to apply an open dialog using uigetfile function
>
>
> if ~ischar(filename)
>
> %on cancel press store me this message in an error dialog
> errordlg('Eroare!','Nici un fisier selectat!');
> return;
> end
>
> img = imread(fullfile(pathname,filename)); %reading the image from path
> imshow(img); %displaying image in axes1
>
> img=imread(fullfile(pathname,filename));
> imshow(var,'parent',handles.axes1);
>
> str = get(handles.listbox1,'string');
> str = cellstr(str);
> str{end+1} = fullfile(pathname,filename);
> set(handles.listbox1,'string',str); %store in listbox1 each path for each file that i store in axes1


I done that! Thanks anyway!

Tags for this Thread

No tags are associated with 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