It can't read an image, it says the path does not exist even though the path does exist
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Steven Lord
le 5 Juin 2021
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.
Réponses (2)
DGM
le 4 Juin 2021
Modifié(e) : DGM
le 4 Juin 2021
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 commentaires
Walter Roberson
le 5 Juin 2021
the code says Left_Index_Finger_165 but the error message says _left_index
Image Analyst
le 5 Juin 2021
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 commentaires
Walter Roberson
le 8 Juin 2021
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
le 8 Juin 2021
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.
Voir également
Catégories
En savoir plus sur Text Data Preparation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!