Shape recognition by neural network
Show older comments
Hello, I would like to ask which Neural Network should I choose. I want to recognition of 3 shape (Square,Circle,Triangle).
I learn my NN with 69 patterns (23 image of Square, 23 Circle etc). First network was "newp" and the second "newff". I have some answers but my network recognition e.g Triangle as Square and Circle or something like this. Any ideas ? Thank !
% PATTERNS
load PatternsSquare
load PatternsCircle
load PatternsTriangle
% SHAPE Square
P1=cell2mat(struct2cell(PatternsSquare));
PS=reshape(P1,40000,23);
% SHAPE Circle
P2=cell2mat(struct2cell(PatternsCircle));
PO=reshape(P1,40000,23);
% SHAPE Triangel
P3=cell2mat(struct2cell(PatternsTriangle));
PT=reshape(P1,40000,23);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NETWORK
P=[PS,PO,PT]; %MATRIX WITH ALL MY PATTERN
T=eye(3,69); %NETWORK ANSWER
%net = newp(P,T,'hardlim','learnp');
net=newff(P,T,[10 10],{'tansig' 'purelin'},'traingd');
net.trainParam.epochs = 50;
net.trainParam.goal=0.00001;
net = train(net,P,T);
Y=sim(net,P);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DISRUPTION
D=imread('T14.png'); % MY DISRUPTION PATTERN
D=im2bw(D);
D=double(D);
[m n] = size(D) ;
D = imresize(D, [200 200]);
[x y] = size(D);
PD=reshape(D,40000,1);
YD=sim(net,PD);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% DISPLAY
figure(1)
for i=1:1
subplot(1,2,i)
imshow(reshape(PD(:,i),200,200))
title('DISRUPTION')
subplot(1,2,2*i)
hintonw(YD(:,i))
title('NEURON: 1-Square, 2-Circle, 3-Triangle')
end
Accepted Answer
More Answers (0)
Categories
Find more on Pattern Recognition in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!