how to solve a error?

조회 수: 2 (최근 30일)
sruthi N
sruthi N 2017년 12월 18일
댓글: Walter Roberson 2017년 12월 18일
My error is
Error in training (line 6)
I{a}=imread(['ImageDataSet/' num2str(a) '.tiff']);
Error in main (line 56)
[traindata, trainlabel]=training(no_of_Image);
function program
function [trdata, trlabel]=training(no_input)
I=cell(no_input,1);
trdata=[];
trlabel=[];
for a=1:no_input
I{a}=imread(['ImageDataSet/' num2str(a) '.tiff']);
end
k= 15;
option = 2;
for i=1:length(I)
[kn]=mkuan(I{i});
ad= anisodiff(kn,k,option);
[Y] = FLDA(ad);
data=reshape(Y,[1,size(Y,1)*size(Y,2)]);
Label=reshape(Y>=max(Y(:)),[1,size(Y,1)*size(Y,2)]);
trdata=[trdata data];
trlabel=[trlabel Label];
end
  댓글 수: 4
sruthi N
sruthi N 2017년 12월 18일
error is here
Error using imread>get_full_filename (line 516) File "ImageDataSet/1.tiff" does not exist.
Error in imread (line 340) fullname = get_full_filename(filename);
Error in training (line 6) I{a}=imread(['ImageDataSet/' num2str(a) '.tiff']);
Error in main (line 56) [traindata, trainlabel]=training(no_of_Image);
Walter Roberson
Walter Roberson 2017년 12월 18일
We, as outsiders, have no reason to expect that file ImageDataSet/1.tiff is definitely going to be there.
You should be testing to see that the files are present before attempting to read them, or else you should be putting in a try/catch to handle the situation of the files not being available.

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

답변 (1개)

Rik
Rik 2017년 12월 18일
Then the answer is in the error message: the file does not exist. Note that your file separator depends on your system. That's the reason you shouldn't hardcode the slashes unless you're certain only 1 file system will handle this code. You can use filesep or fullfile instead. It might also be best to use an explicit path. You can use pwd to get the current directory, or use dbstack('-completenames') to get the folder of the function that is running.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by