how to select image from a particular folder

i wanted to select an image from a folder named dataset....
[filename pathname]=uigetfile('*.tif','Select An Image');
when i do so, i have to select the Dataset folder and then the image from it.... what shud i do so that on execution itself the images will be displayed so that i neednt select on Dataset folder and then images

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 13 Mär. 2013

0 Stimmen

Read the documentation.
FilterSpec can include a path. That path can contain '.','..', \, '/', or '~'. For example, '../*.m' lists all code files in the folder above the current folder.

9 Kommentare

Elysi Cochin
Elysi Cochin am 13 Mär. 2013
Bearbeitet: Elysi Cochin am 13 Mär. 2013
sir this is my path..... % C:\Users\user\Desktop\Desktop Folder\ProjectWork\Full_Project\Coding\Dataset
i did like this
[filename pathname]=uigetfile('..\Dataset_Iris\*.png');
irisImage=imread([pathname filename]);
but it is not opening Dataset folder..... it shows the Full_Project folder...... please do reply sir..
how to make the change sir.... please do reply....
Walter Roberson
Walter Roberson am 13 Mär. 2013
Which part of your uigetfile() call is the FilterSpec ? Change that part.
Elysi Cochin
Elysi Cochin am 13 Mär. 2013
Bearbeitet: Elysi Cochin am 13 Mär. 2013
i'm not getting sir.... i did like this....
[FileName,PathName,FilterIndex] = uigetfile('FilterSpec','Dataset/*.png');
irisImage=imread([FileName PathName]);
Walter Roberson
Walter Roberson am 13 Mär. 2013
What directory are you cd'd to at the time you run the uigetfile() ? What directory do you want to look in for the images?
C:\Users\user\Desktop\Desktop Folder\ProjectWork\Full_Project\Coding\Dataset.....
sir this is the path....
Dataset folder contains images.... i want those images to be opened in that window which gets opened to select an image.....
Image Analyst
Image Analyst am 13 Mär. 2013
Bearbeitet: Image Analyst am 13 Mär. 2013
uigetfile() will not open images though if you're using Windows, you can tell it to show images as thumbnails (mini-images). Otherwise, adapt your code like:
folder = 'C:\Users\user\Desktop\Desktop Folder\ProjectWork\Full_Project\Coding\Dataset';
filePattern = fullfile(folder, '*.png';
[FileName,PathName,FilterIndex] = uigetfile(filePattern );
Elysi Cochin
Elysi Cochin am 13 Mär. 2013
thank u sir... that was what i wanted exactly.... but if i copy the ProjectWork folder to another location... the path changes..... is it possible to do by coding.... even if i change the location of my "ProjectWork" folder i obtain the above result as u showed......
ProjectWork\Full_Project\Coding\Dataset'..... this remains the same..... can i do anything sir...
Walter Roberson
Walter Roberson am 13 Mär. 2013
You can search your entire filesystem to try to find ProjectWork
Or, you can answer my earlier question "What directory are you cd'd to at the time you run the uigetfile() "
Image Analyst
Image Analyst am 13 Mär. 2013
What I do in that case (the folder you were expecting, say the folder you used last time you ran the program, cannot be found) is to bring up a file browse dialog box, like uigetdir() or uipickfiles, and have the user locate it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Said Akram Anwarzai
Said Akram Anwarzai am 24 Apr. 2020

0 Stimmen

[filename pathname]=uigetfile('*.tif','Select An Image');

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by