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....
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]);
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 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...
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() "
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 Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by