what is the problem in my following face recognition code?

조회 수: 2 (최근 30일)
uday
uday 2013년 7월 18일
댓글: omar shall 2014년 1월 16일
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
uday
uday 2013년 7월 18일
thank you cyclist
omar shall
omar shall 2014년 1월 16일
Does this code compares a picture to pictures in database? if yes can you please add the edited file please

댓글을 달려면 로그인하십시오.

채택된 답변

the cyclist
the cyclist 2013년 7월 18일
Line 28 of your code is attempting to reshape Q into a 64x1 vector. The error is saying that there are not 64 elements in Q, the operation is impossible. You could breakpoint your code at line 27 to see why Q doesn't have the number of elements you expect.
  댓글 수: 2
uday
uday 2013년 7월 18일
how will i know the number of elements in my input image i.e Q?
Matt Kindig
Matt Kindig 2013년 7월 18일
Shot in the dark, but I think this should work:
Q = double(reshape(Q,64,[]));
Note that second parameter is empty ([]) rather than 1. Keep in mind this approach only works in the number of elements in Q (from the previous imread() call) is divisible by 64, i.e.,
numel(Q)/64
yields a whole number.
If that is not the case, you will also need to resample the image to a 64xN image using imresize() or similar. In that case, this should work:
Q = double(imresize(Q, [64 NaN]));

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 7월 18일
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?
  댓글 수: 1
uday
uday 2013년 7월 18일
Q=imread('hulk6.jpg') do you mean to say that the above image hulk have 10 to 20 megapixels in it or this images P=[r h b bd]? hulk is the image 0f dimension 512*512 which is taken from a 2 megapixel camera and r,h,b,bd are the images after dct conversion of 8*8 net=newsom(minmax(P),[64 2]); Q=double(reshape(Q,64,1)); so what would be the appropriate number of the Q? r give me the idea how can i know it

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by