Excuse me guys, I found the problem on projects that I have made. I want to compare the input 1 to input 2, where the result is an image Circle or Uncircle. Can you help me to fix it? Thank you.
This is a 10x10 matrix, but it does not work as expected.
[/spoiler = Code]
clc; %I = imread('D:\Documents\Lecture Files\Semester 8\BPJST\Praktek\Coin\box1.jpg'); %p = im2bw(I); %figure, imshow(I); %figure, imshow(p);
t = [0 1];
w1 = rand(5,100);
w2 = rand(1,5);
b1 = rand(1,5); %Layer 1 Bias Initial Value b2 = rand(1,1); %Layer 2 Bias Initial Value
alpha = 0.001; e = 1; it = 0;
while it < 1000
error = 0 + 1; it = it + 1; disp('Iteration'); disp(it);
for i = 1:2
if i == 1
I1 = imread('C:\Users\DELL\Pictures\Coin\coin1.jpg');
p = im2bw(I1);
a0 = [p(1,1) p(1,2) p(1,3) p(1,4) p(1,5) p(1,6) p(1,7) p(1,8) p(1,9) p(1,10) p(2,1) p(2,2) p(2,3) p(2,4) p(2,5) p(2,6) p(2,7) p(2,8) p(2,9) p(2,10) p(3,1) p(3,2) p(3,3) p(3,4) p(3,5) p(3,6) p(3,7) p(3,8) p(3,9) p(3,10) p(4,1) p(4,2) p(4,3) p(4,4) p(4,5) p(4,6) p(4,7) p(4,8) p(4,9) p(4,10) p(5,1) p(5,2) p(5,3) p(5,4) p(5,5) p(5,6) p(5,7) p(5,8) p(5,9) p(5,10) p(6,1) p(6,2) p(6,3) p(6,4) p(6,5) p(6,6) p(6,7) p(6,8) p(6,9) p(6,10) p(7,1) p(7,2) p(7,3) p(7,4) p(7,5) p(7,6) p(7,7) p(7,8) p(7,9) p(7,10) p(8,1) p(8,2) p(8,3) p(8,4) p(8,5) p(8,6) p(8,7) p(8,8) p(8,9) p(8,10) p(9,1) p(9,2) p(9,3) p(9,4) p(9,5) p(9,6) p(9,7) p(9,8) p(9,9) p(9,10) p(10,1) p(10,2) p(10,3) p(10,4) p(10,5) p(10,6) p(10,7) p(10,8) p(10,9) p(10,10)]';
a1 = logsig(w1*a0+b1');
a2 = purelin(w2*a1+b2);
e = t(1,i)-a2;
error = error + abs(e);
elseif i == 2
I2 = imread('C:\Users\DELL\Pictures\Coin\box1.jpg');
p1 = im2bw(I2);
c0 = [p1(1,1) p1(1,2) p1(1,3) p1(1,4) p1(1,5) p1(1,6) p1(1,7) p1(1,8) p1(1,9) p1(1,10) p1(2,1) p1(2,2) p1(2,3) p1(2,4) p1(2,5) p1(2,6) p1(2,7) p1(2,8) p1(2,9) p1(2,10) p1(3,1) p1(3,2) p1(3,3) p1(3,4) p1(3,5) p1(3,6) p1(3,7) p1(3,8) p1(3,9) p1(3,10) p1(4,1) p1(4,2) p1(4,3) p1(4,4) p1(4,5) p1(4,6) p1(4,7) p1(4,8) p1(4,9) p1(4,10) p1(5,1) p1(5,2) p1(5,3) p1(5,4) p1(5,5) p1(5,6) p1(5,7) p1(5,8) p1(5,9) p1(5,10) p1(6,1) p1(6,2) p1(6,3) p1(6,4) p1(6,5) p1(6,6) p1(6,7) p1(6,8) p1(6,9) p1(6,10) p1(7,1) p1(7,2) p1(7,3) p1(7,4) p1(7,5) p1(7,6) p1(7,7) p1(7,8) p1(7,9) p1(7,10) p1(8,1) p1(8,2) p1(8,3) p1(8,4) p1(8,5) p1(8,6) p1(8,7) p1(8,8) p1(8,9) p1(8,10) p1(9,1) p1(9,2) p1(9,3) p1(9,4) p1(9,5) p1(9,6) p1(9,7) p1(9,8) p1(9,9) p1(9,10) p1(10,1) p1(10,2) p1(10,3) p1(10,4) p1(10,5) p1(10,6) p1(10,7) p1(10,8) p1(10,9) p1(10,10)]';
c1 = logsig(w1*a0+b1');
c2 = purelin(w2*a1+b2);
e = t(1,i)-a2;
error = error + abs(e);
end
%%Backpropagation f2 = 1; s2 = -2*f2*e; f1 = [ (1-a1(1))*a1(1) 0 0 0 0 ; 0 (1-a1(2))*a1(2) 0 0 0 ; 0 0 (1-a1(3))*a1(3) 0 0 ; 0 0 0 (1-a1(4))*a1(4) 0 ; 0 0 0 0 (1-a1(5))*a1(5) ]; s1=f1*w2'*s2;
%%Update weight and bias for layer 1 and layer 2 w2 = w2 - alpha*s2*a1'; b2 = b2 - alpha*s2; w1 = w1 - alpha*s1*a0'; b1 = b1 - alpha*s1';
end end % w1 = (1-gamma)*w1 + alpha*a*p(i); %a = hardlim(w1*p(1,i) + w1*p(1,i) + b2);
%%Test the network I2 = imread('C:\Users\DELL\Pictures\Coin\box1.jpg'); p3 = im2bw(I2); % figure,imshow(I2); d0=[p3(1,1) p3(1,2) p3(1,3) p3(1,4) p3(1,5) p3(1,6) p3(1,7) p3(1,8) p3(1,9) p3(1,10) p3(2,1) p3(2,2) p3(2,3) p3(2,4) p3(2,5) p3(2,6) p3(2,7) p3(2,8) p3(2,9) p3(2,10) p3(3,1) p3(3,2) p3(3,3) p3(3,4) p3(3,5) p3(3,6) p3(3,7) p3(3,8) p3(3,9) p3(3,10) p3(4,1) p3(4,2) p3(4,3) p3(4,4) p3(4,5) p3(4,6) p3(4,7) p3(4,8) p3(4,9) p3(4,10) p3(5,1) p3(5,2) p3(5,3) p3(5,4) p3(5,5) p3(5,6) p3(5,7) p3(5,8) p3(5,9) p3(5,10) p3(6,1) p3(6,2) p3(6,3) p3(6,4) p3(6,5) p3(6,6) p3(6,7) p3(6,8) p3(6,9) p3(6,10) p3(7,1) p3(7,2) p3(7,3) p3(7,4) p3(7,5) p3(7,6) p3(7,7) p3(7,8) p3(7,9) p3(7,10) p3(8,1) p3(8,2) p3(8,3) p3(8,4) p3(8,5) p3(8,6) p3(8,7) p3(8,8) p3(8,9) p3(8,10) p3(9,1) p3(9,2) p3(9,3) p3(9,4) p3(9,5) p3(9,6) p3(9,7) p3(9,8) p3(9,9) p(9,10) p3(10,1) p3(10,2) p3(10,3) p3(10,4) p3(10,5) p3(10,6) p3(10,7) p3(10,8) p3(10,9) p3(10,10)]'; %Input sampe 100; d1=logsig(w1*a0+b1'); d2=purelin(w2*a1+b2);
x=(a2*c2)/d2; % if (a2==d2) disp('circle');
else disp('Uncircle'); end
[/spoiler]