Hi,
I downloaded an image dataset called DB1_B, and I want to read all images into an array. I tried using dir() directly, but got an error, searched for a solution and found this instead, but I'm still getting errors?
folder = uigetdir('C:\Users\Mia\Documents\Project (SD)\DB1_B');
tiffile = dir(folder, '*.tif');
numfiles = length(tiffile);
mydata = cell(1,numfiles);
for k = 1:numfiles
mydata{k} = imread(tiffile(k).name)
end
Error using dir
Too many input arguments.
Error in NNexLBP (line 3)
tifffile = dir(folder, '*.tif');
Its 80 images if that makes a difference? I have a test code that successfully extracts one image by using
im = imread('C:\Users\Mia\Documents\Project (SD)\DB1_B\101_1.tif');
so I think it's directed correctly? The test code and the code I'm trying to use now are saved in different folders, but they're both saved under the 'project (SD)' folder if that makes a difference?

 채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 13일

0 개 추천

tiffile = dir( fullfile(folder, '*.tif'));
and
mydata{k} = imread( fullfile(folder, tiffile(k).name) );

댓글 수: 1

Mia
Mia 2020년 5월 13일
Ah thank you so much! That works perfectly, have a lovely day!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Mario Malic
Mario Malic 2020년 5월 13일

0 개 추천

The extra backward slash should do it.
folder = uigetdir('C:\Users\Mia\Documents\Project (SD)\DB1_B\');

댓글 수: 2

Walter Roberson
Walter Roberson 2020년 5월 13일
No, this is not actually correct. No matter what input you pass to uigetdir(), you do not know whether the output will end in a \ or / or not.
Mario Malic
Mario Malic 2020년 5월 13일
My bad.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

질문:

Mia
2020년 5월 13일

댓글:

2020년 5월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by