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

Image Analyst
Image Analyst 2021년 12월 9일
give the complete error message, not just a snippet of it. We need ALL THE RED TEXT, not just part of it.
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), '');

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

 채택된 답변

yanqi liu
yanqi liu 2021년 12월 10일
편집: yanqi liu 2021년 12월 10일

0 개 추천

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), '');

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Deep Learning for Image Processing에 대해 자세히 알아보기

질문:

2021년 12월 9일

편집:

2021년 12월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by