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

 採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 13 日

0 投票

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 件のコメント

Elysi Cochin
Elysi Cochin 2013 年 3 月 13 日
編集済み: Elysi Cochin 2013 年 3 月 13 日
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 2013 年 3 月 13 日
Which part of your uigetfile() call is the FilterSpec ? Change that part.
Elysi Cochin
Elysi Cochin 2013 年 3 月 13 日
編集済み: Elysi Cochin 2013 年 3 月 13 日
i'm not getting sir.... i did like this....
[FileName,PathName,FilterIndex] = uigetfile('FilterSpec','Dataset/*.png');
irisImage=imread([FileName PathName]);
Walter Roberson
Walter Roberson 2013 年 3 月 13 日
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?
Elysi Cochin
Elysi Cochin 2013 年 3 月 13 日
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 2013 年 3 月 13 日
編集済み: Image Analyst 2013 年 3 月 13 日
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 2013 年 3 月 13 日
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 2013 年 3 月 13 日
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 2013 年 3 月 13 日
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.

サインインしてコメントする。

その他の回答 (1 件)

Said Akram Anwarzai
Said Akram Anwarzai 2020 年 4 月 24 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by