what is the problem in my following face recognition code?
Show older comments
i dont know this is my code......
load data.mat
%Declare training data
P=[r h b bd];
%Create SOM neural network
%(64 minimum points and 64 maximum points)
net=newsom(minmax(P),[64 2]);
%Train SOM neural network for 1000 epochs
net.trainParam.epochs=100;
net=train(net,P);
%Plot SOM layer weights
x=net.iw{1,1},net.layers{1}.distances;
figure, plot(dist(x),'o');
title('SOM Layer Weights');
xlabel('Layer Weights');
ylabel('Magnitude');
%Plot SOM weight vectors
figure, plotsom(net.iw{1,1},net.layers{1}.distances)
sx=sim(net,P);
[l,m]=size(sx);
for u=1:1:m
sm(u)=find(sx(:,u));
end
%Load input face image
Q=imread('hulk6.jpg');
Q=double(reshape(Q,64,1));%(28 line)
i am getting the error
??? Error using ==> reshape
To RESHAPE the number of elements must not change.
Error in ==> simsom at 28
Q=double(reshape(Q,64,1));
what is the problem
5 Comments
Jos (10584)
on 18 Jul 2013
Edited: Jos (10584)
on 18 Jul 2013
There are two problems:
- format your question using "{} Code"
- You get an error when you run the code.
Luckily, the error message is pretty clear: Q does not have 64 elements in it!
the cyclist
on 18 Jul 2013
Edited: the cyclist
on 18 Jul 2013
@uday: I edited your code to be more readable (using the "{}Code" functionality that Jos mentioned).
uday
on 18 Jul 2013
omar shall
on 16 Jan 2014
Does this code compares a picture to pictures in database? if yes can you please add the edited file please
Accepted Answer
More Answers (1)
Image Analyst
on 18 Jul 2013
0 votes
Q is an entire image. It probably has 10 or 20 megapixels in it. Why do you think it has only 64 pixels in it?
Categories
Find more on Semantic Segmentation 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!