It is a coding function net1.net to detect images
clc;clear;close all;
image_folder = ‘daftar uang’;
filenames = dir(fullfile(image_folder, ‘*.jpg’));
total_images = numel(filenames);
for n = 1:total_images
full_name= fullfile(image_folder, filenames(n).name);
I = imread(full_name);
J = I(:,:,1);
K = imbinarize(J,.6);
L = imcomplement(K);
str = strel(‘disk’,5);
M = imclose(L,str);
N = imfill(M,’holes’);
O = bwareaopen(N,1000);
stats = regionprops(O,’Area’,’Perimeter’,’Eccentricity’);
area(n) = stats.Area;
perimeter(n) = stats.Perimeter;
metric(n) = 4*pi*area(n)/(perimeter(n)^2);
eccentricity(n) = stats.Eccentricity;
end
input = [metric;eccentricity];
target = zeros(1,48);
target(:,1:12) = 1;
target(:,13:24) = 2;
target(:,25:36) = 3;
target(:,37:48) = 4;
net = newff(input,target,[10 5],{‘logsig’,’logsig’},’trainlm’);
net.trainParam.epochs = 1000;
net.trainParam.goal = 1e-6;
net = train(net,input,target);
output = round(sim(net,input));
save net1.mat net
[m,n] = find(output==target);
akurasi = sum(m)/total_images*100
"Why is the accuracy I get only 25%? help me please?"clc;clear;close all;
image_folder = ‘daftar uang’;
filenames = dir(fullfile(image_folder, ‘*.jpg’));
total_images = numel(filenames);
for n = 1:total_images
full_name= fullfile(image_folder, filenames(n).name);
I = imread(full_name);
J = I(:,:,1);
K = imbinarize(J,.6);
L = imcomplement(K);
str = strel(‘disk’,5);
M = imclose(L,str);
N = imfill(M,’holes’);
O = bwareaopen(N,1000);
stats = regionprops(O,’Area’,’Perimeter’,’Eccentricity’);
area(n) = stats.Area;
perimeter(n) = stats.Perimeter;
metric(n) = 4*pi*area(n)/(perimeter(n)^2);
eccentricity(n) = stats.Eccentricity;
end
input = [metric;eccentricity];
target = zeros(1,48);
target(:,1:12) = 1;
target(:,13:24) = 2;
target(:,25:36) = 3;
target(:,37:48) = 4;
net = newff(input,target,[10 5],{‘logsig’,’logsig’},’trainlm’);
net.trainParam.epochs = 1000;
net.trainParam.goal = 1e-6;
net = train(net,input,target);
output = round(sim(net,input));
save net1.mat net
[m,n] = find(output==target);
akurasi = sum(m)/total_images*100
"Why is the accuracy I get only 25%? help me please?" clc;clear;close all;
image_folder = ‘daftar uang’;
filenames = dir(fullfile(image_folder, ‘*.jpg’));
total_images = numel(filenames);
for n = 1:total_images
full_name= fullfile(image_folder, filenames(n).name);
I = imread(full_name);
J = I(:,:,1);
K = imbinarize(J,.6);
L = imcomplement(K);
str = strel(‘disk’,5);
M = imclose(L,str);
N = imfill(M,’holes’);
O = bwareaopen(N,1000);
stats = regionprops(O,’Area’,’Perimeter’,’Eccentricity’);
area(n) = stats.Area;
perimeter(n) = stats.Perimeter;
metric(n) = 4*pi*area(n)/(perimeter(n)^2);
eccentricity(n) = stats.Eccentricity;
end
input = [metric;eccentricity];
target = zeros(1,48);
target(:,1:12) = 1;
target(:,13:24) = 2;
target(:,25:36) = 3;
target(:,37:48) = 4;
net = newff(input,target,[10 5],{‘logsig’,’logsig’},’trainlm’);
net.trainParam.epochs = 1000;
net.trainParam.goal = 1e-6;
net = train(net,input,target);
output = round(sim(net,input));
save net1.mat net
[m,n] = find(output==target);
akurasi = sum(m)/total_images*100
"Why is the accuracy I get only 25%? help me please?" transferred MATLAB Answers — New Questions