clc; clear; close all; warning off all;
nama_folder = 'DATA LATIH';
nama_file = dir(fullfile(nama_folder,'*.png*'));
jumlah_file = numel(nama_file);
ciri_latih = zeros(jumlah_file,8);
chain_code = zeros(jumlah_file,8);
A = imread(fullfile(nama_folder,nama_file(n).name));
sobelhor = [-1 0 1; -2 0 2; -1 0 1];
sobelver = [-1 -2 -1; 0 0 0; 1 2 1];
I1 = conv2(C,sobelhor,'same');
I2 = conv2(C,sobelver,'same');
D = sqrt((I1.^2)+(I2.^2));
chain_code(n,1) = sum(cc{1,1}.code==0);
chain_code(n,2) = sum(cc{1,1}.code==1);
chain_code(n,3) = sum(cc{1,1}.code==2);
chain_code(n,4) = sum(cc{1,1}.code==3);
chain_code(n,5) = sum(cc{1,1}.code==4);
chain_code(n,6) = sum(cc{1,1}.code==5);
chain_code(n,7) = sum(cc{1,1}.code==6);
chain_code(n,8) = sum(cc{1,1}.code==7);