Classify photos based on their labels

6 visualizzazioni (ultimi 30 giorni)
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
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.
Farhad Abedinzadeh
Farhad Abedinzadeh il 9 Dic 2021
I'm sorry for the mistake,for simplicity, I renamed the photos from 0 to 6391, and also numbered the labels from 0 to 7, for example, I replaced the normal class which is is located in the above table with the letter ['N'] with 0, the Diabetes class which is is located in the above table with the letter ['D'] have replaced with 1, and so on for other diseases up to 7.
And I saved the new labels in a new Excel file, then I called that new file in MATLAB and got the following error.
error:
Brace indexing is not supported for variables of this type.
Error in maincode (line 25)
current_filename=strrep(filename{idx}, char(39), '');

Accedi per commentare.

Risposta accettata

yanqi liu
yanqi liu il 10 Dic 2021
Modificato: yanqi liu il 10 Dic 2021
yes,sir,may be upload full_df.xlsx
now,i thinke filename is numberic vector, so
current_filename=strrep(filename{idx}, char(39), '');
use
disp(filename)
current_filename=strrep(num2str(filename(idx)), char(39), '');

Più risposte (0)

Categorie

Scopri di più su Image Data Workflows in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by