Classify photos based on their labels
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Farhad Abedinzadeh
il 9 Dic 2021
Modificato: yanqi liu
il 10 Dic 2021
I'm a newbie to image processing with MATLAB. Please help me to modify the code
I am working on a database that contains 6392 images of left and right eye images. Each of these images has a different label, which is placed in an Excel file based on the name of the images.
dataset:(https://www.kaggle.com/andrewmvd/ocular-disease-recognition-odir5k)
I wrote the following script to categorize images based on labels, but unfortunately I got an error.
"Brace indexing is not supported for variables of this type."
Please help me correct the code.
Code and screenshots of images and labels are attached at the bottom.
datapath='C:\Users\FarHad\Downloads\Compressed\ODIRK\preprocessed_images';
% Two-class Data path
multi_class_datapath='C:\Users\FarHad\Downloads\Compressed\ODIRK\preprocessed_images\right';
% Class Names
class_names={'Normal','Diabetes','Glaucoma','Cataract','AMD','Hypertension','Myopia','OtherDiseases'};
mkdir(sprintf('%s%s',multi_class_datapath,class_names{1}))
mkdir(sprintf('%s%s',multi_class_datapath,class_names{2}))
mkdir(sprintf('%s%s',multi_class_datapath,class_names{3}))
mkdir(sprintf('%s%s',multi_class_datapath,class_names{4}))
mkdir(sprintf('%s%s',multi_class_datapath,class_names{5}))
mkdir(sprintf('%s%s',multi_class_datapath,class_names{6}))
mkdir(sprintf('%s%s',multi_class_datapath,class_names{7}))
mkdir(sprintf('%s%s',multi_class_datapath,class_names{8}))
% Read the Excel Sheet with Labels
[num_data]=xlsread('full_df.xlsx');
% Determine the Labels
train_labels=num_data(:,end);
% Filename
filename=num_data(1:end,2);
% Determine the Files put them in separate folder
for idx=1:length(filename)
% You could uncomment if you would like to see live progress
% fprintf('Processing %d among %d files:%s \n',idx,length(filename),filename{idx})[/%]
% Read the image
current_filename=strrep(filename{idx}, char(39), '');
img=imread(sprintf('%s%s.jpg',datapath,current_filename));
% Write the image in the respective folder
imwrite(img,sprintf('%s%s%s%s.jpg',multi_class_datapath,class_names{train_labels(idx)},'\',current_filename));
clear img;
end
2 Commenti
Image Analyst
il 9 Dic 2021
give the complete error message, not just a snippet of it. We need ALL THE RED TEXT, not just part of it.
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Image Data Workflows in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!