我正在研究水果中的疾病 我想将几百种疾病的图像上传到.mat文件并将其存储为数字 例如:疾病1 = 0,疾病2 = 1 ......等 然后将它们用作multiSVM的训练数据 我怎么能在matlab中实现它? p.s我是matlab的新手
我试过这段代码,但它没有存储任何值:
function IMGDB = loadimages
BlossomEndRot_folder = 'Learning/';
FruitCracks_folder = 'Diseases/Fruit Cracks/Learning';
file_ext1 = '.png';
D1 = 0;
D2 = 1;
if exist('imagedb.mat','file')
load imagedb;
else
IMGDB = cell (2,[]);
end
fprintf ('Loading Diseases');
folder_content1 = dir ([BlossomEndRot_folder,'*',file_ext1]);
NumOfDiseaseImgs = size (folder_content1,1);
for k=1:NumOfDiseaseImgs
string = [BlossomEndRot_folder,folder_content1(k,1).name];
image = imread(string);
[m n] = size(image);
f=0;
for i=1:length(IMGDB)
if strcmp(IMGDB{1,i},string)
f=1;
end
end
if f==1
continue;
end
fprintf ('.');
IMGDB {1,end+1}= string;
IMGDB {2,end} = D1;
end
fprintf('\n');
save imagedb IMGDB;