It can't read an image, it says the path does not exist even though the path does exist

조회 수: 6 (최근 30일)
clc
close all
clear all
imgpath{4}= 'D:\MATLAB\Finger_Knuckle_Print_Original_Database\Left_Index_Finger_165\';
fd4=fopen('loglist_Left_Index.txt','rt'); % 294 subjects Train Total train = 493
feat1=[];
k=6;
for i=1:165
txt1=fscanf(fd4,'%s\n',1);
for j=1:6
fn1=sprintf('%s/%s index/0%iROI.jpg',imgpath{4},txt1,j); %u01000s0001_fnf1.jpg
img1=imread(fn1);
F=[]
H=slbp(img1);
F=[F;H(:)];
P=ridgelet(img1,0);
QQ=q(F,P);
feat_test=[ feat_test [reshape(QQ ( :,:,1 ) ,[ ],1 )] ];
end
end
  댓글 수: 3
Steven Lord
Steven Lord 2021년 6월 5일
You have asked this question 1, 2, 3, and 4 times and received answers and/or comments on three of those questions.
Asking the same thing multiple times is not necessarily likely to get you different answers. It's likely to get you the same answer multiple times.
Please pick one of these questions and continue the discussion in that one question. Please don't ask this a fifth time.
John D'Errico
John D'Errico 2021년 6월 5일
4 identical questions on the same day. I closed one of them.

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

답변 (2개)

DGM
DGM 2021년 6월 4일
편집: DGM 2021년 6월 4일
Nobody here can guess the contents of the index file you're reading or the actual filenames on your disk. You can start by generating a short list (e.g. 2 or 3) of the filenames assembled by fn1. Then go find the full path+filename+extension for those files. Do they differ? If so, why? It helps to paste them into a text file and look at them directly next to each other. It's easy to miss little details.
I said I couldn't guess, but I'll guess anyway. If you're running windows, directory separators are \, not ./. If you want, you can build the full path expression using fullfile(), which will automatically use whichever is appropriate. EDIT: see Stephen's comment below.
  댓글 수: 7
Walter Roberson
Walter Roberson 2021년 6월 5일
the code says Left_Index_Finger_165 but the error message says _left_index

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


Image Analyst
Image Analyst 2021년 6월 5일
You did not use the fullfile() function, and so you have a forward and backward slash next to each other creating a bogus filename.
"D:\MATLAB\Finger_Knuckle_Print_Original_Database\Left_Index_Finger_165\/_left index/01ROI.jpg"
^^
Bad Characters Here
Try this:
imgpath{4}= 'D:\MATLAB\Finger_Knuckle_Print_Original_Database\Left_Index_Finger_165';
fd4=fopen('loglist_Left_Index.txt','rt'); % 294 subjects Train Total train = 493
feat1=[];
k=6;
for k1 = 1 : 165
txt1=fscanf(fd4,'%s\n',1);
for k2 = 1 : 6
baseName = sprintf('%s index/0%iROI.jpg', txt1, k2); %u01000s0001_fnf1.jpg
fullFileName = fullfile(imgpath{4}, baseName)
img1=imread(fullFileName);
F=[]
H=slbp(img1);
F=[F;H(:)];
P=ridgelet(img1,0);
QQ=q(F,P);
feat_test=[ feat_test [reshape(QQ ( :,:,1 ) ,[ ],1 )] ];
end
end
  댓글 수: 28
Walter Roberson
Walter Roberson 2021년 6월 8일
filename = 'loglist_Left_index.txt';
[fid, message] = fopen(filename, 'wt');
if fid < 0
error('Could not open file "%s" because "%s"', filename, message);
end
for K = 1 : 165
fprintf(fid, '%03d_left\n', K);
end
fclose(fid);
fprint('file "%s" created.\n', filename);
After running that, you should be able to run your code.
Walter Roberson
Walter Roberson 2021년 6월 8일
Your code will need the line
baseName = sprintf('%s index/%02dROI.jpg', txt1, k2);
In particular the line must not have the underscore in it, and must not have the "left" in it. The "left" and the underscore are part of the text file you are reading.

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

카테고리

Help CenterFile Exchange에서 Language Support에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by