clc; clear; close all;
image_folder ='data latih';
filenames = dir(fullfile(image_folder, '*.jpg'));
[jumlah_data] = numel(filenames);
data_latih = zeros(jumlah_data,5);
for k = 1:jumlah_data
full_name = fullfile(image_folder, filenames(k).name);
Img = imread(full_name);
Img = rgb2gray(Img);
H = imhist(Img)';
H = H/sum(H);
I = (0:255);
CiriMEAN = I * H;
CiriENT = -H * log2(H+eps)';
CiriVAR = (I-CiriMean).^2*H';
CiriSKEW = (I-CiriMean).^3*H'/ CiriVAR^1.5;
CiriKURT = (I-CiriMean).^4*H'/ CiriVAR^2-3;
data_latih(k,:) = [CiriMEAN,CiriENT,CiriVAR,CiriSKEW,CiriSKURT];
end
target_latih = zeros(1,jumlah_data);
target_latih(1:6) = 1;
target_latih(7:12) = 2;
target_latih(13:18) = 3;
target_latih(19:24) = 4;
target_latih(25:30) = 5;
output = multivsm(data_latih,target_latih,data_latih);
[n,~] = find(targer_latihan==output');
jumlah_benar = sum(n);
akurasi = jumlah_benar/jumlah_data*100;
save data_latih data_latih
save target_latih target_latih
Best Answer