I am get error like this
Matrix index is out of range for deletion.Error in angkaaa (line 19)huruflist(1) = [];
Im use regionprops (eccentricity, area, perimeter) and use svm multi class for clasification
This my code
close allclear alle = imread('E:\Latihan MATLAB\Project_UAS\Training\huruf-i\4.jpg');figure, imshow(e);t = graythresh(e);imbw_otsu = im2bw(e,t);figure, imshow(imbw_otsu);se = strel('disk',1);citra_close = imclose(e,se);figure, imshow(citra_close);imbw_manual = im2bw(citra_close, 115/255);figure, imshow(imbw_manual);imbw_manual3 = 1 - imbw_manual;figure, imshow(imbw_manual3);traindir = 'Training'; testdir = 'Testing'; huruflist = dir(traindir); huruflist(1) = []; huruflist(1) = [];huruflist = {huruflist.name}';test_data = [];for i=1:size(huruflist,1) train_kelas = huruflist{i}; imglist = dir([traindir '\' train_kelas]); imglist(1) = []; imglist(1) = []; imglist = {imglist.name}'; for j=1:size(imglist,1) imgname = imglist{j}; iminput = imread([traindir '\' train_kelas '\' imgname]); imgray = rgb2gray(iminput); s = regionprops(imbw, 'Eccentricity', 'Area', 'Perimeter'); eccentricity = cat(1, s.Eccentricity); area = cat(1, s.Area); perimeter = cat(1, s.Perimeter); rasio_luaskeliling = area / perimeter; test_data = [test_data; {train_kelas}, imgname, rasio_luaskeliling]; endendxlswrite('train_features.xlsx', test_data, 1, 'A1');testlisthuruf = dir(testdir); testlisthuruf(1) = []; testlisthuruf(1) = [];testlisthuruf = {testlisthuruf.name}';testimgdir = 'Test Images';if ~exist(testimgdir) mkdir(testimgdir);endtest_data = [];for i=1:size(testlist,1) imgname = testlist{i}; test_class = imgname(1:end-4); iminput = imread([testdir '\' imgname]); imgray = rgb2gray(iminput); s = regionprops(imbw, 'Eccentricity', 'Area', 'Perimeter'); eccentricity = cat(1, s.Eccentricity); area = cat(1, s.Area); perimeter = cat(1, s.Perimeter); rasio_luaskeliling = area / perimeter; test_data = [test_data; {train_kelas}, imgname, rasio_luaskeliling];end[num, raw] = xlsread('train_features.xlsx');trainX = num(:,:);trainY = raw(:,1);testX = cell2mat(test_data(:,2:end));testY = test_data(:,1);categories = {'huruf-a';'huruf-e';'huruf-i';'huruf-o';'huruf-u'};result = cell(size(testY));numClasses = size(categories,1);for i=1:numClasses G1vAll=(strcmp(trainY,categories(i))); models(i) = svmtrain(trainX, G1vAll, 'kernel_function', 'linear');endfor i=1:size(testX,1) for j=1:numClasses if(svmclassify(models(j),testX(i,:))) break; end end result(i) = categories(j);endaccuracy = 0; for i=1:size(result,1) if (strcmp(result(i),testY(i))) accuracy = accuracy + 1; endend[gr_w gr_h] = size(testY);accuracy = (accuracy / gr_w)*100;disp(['Akurasi = ' num2str(accuracy) '%']);
And i want result like this.
>> exampleAkurasi = 100%
Thank you so much before.
Best Answer