ctranspose Transpose on ND array is not defined.

face recognition program
% Acquire new image
% Note: the input image must have a bmp or jpg extension.
% It should have the same size as the ones in your training set.
% It should be placed on your desktop
InputImage = input('Please enter the name of the image and its extension \n','s');
InputImage = imread(strcat('C:\Users\Sudha\Desktop\',InputImage));
figure(5)
subplot(1,2,1)
imshow(InputImage); colormap('gray');title('Input image','fontsize',18)
InImage=reshape(double(InputImage)',irow*icol,1);
temp=InImage;
me=mean(temp);
st=std(temp);
temp=(temp-me)*ustd/st+um;
NormImage = temp;
Difference = temp-m;
p = [];
aa=size(u,2);
for i = 1:aa
pare = dot(NormImage,u(:,i));
p = [p; pare];
end
ReshapedImage = m + u(:,1:aa)*p; %m is the mean image, u is the eigenvector
ReshapedImage = reshape(ReshapedImage,icol,irow);
ReshapedImage = ReshapedImage';
%show the reconstructed image.
subplot(1,2,2)
imagesc(ReshapedImage); colormap('gray');
title('Reconstructed image','fontsize',18)
InImWeight = [];
for i=1:size(u,2)
t = u(:,i)';
WeightOfInputImage = dot(t,Difference');
InImWeight = [InImWeight; WeightOfInputImage];
end
ll = 1:M;
figure(68)
subplot(1,2,1)
stem(ll,InImWeight)
title('Weight of Input Face','fontsize',14)
% Find Euclidean distance
e=[];
for i=1:size(omega,2)
q = omega(:,i);
DiffWeight = InImWeight-q;
mag = norm(DiffWeight);
e = [e mag];
end
kk = 1:size(e,2);
subplot(1,2,2)
stem(kk,e)
title('Eucledian distance of input image','fontsize',14)
MaximumValue=max(e);
MinimumValue=min(e);
the error is
??? Error using ==> ctranspose
Transpose on ND array is not defined.
Error in ==> Mio at 164
InImage=reshape(double(InputImage)',irow*icol,1);
plz help me solve this error...

1 commentaire

José-Luis
José-Luis le 12 Fév 2013
Modifié(e) : José-Luis le 12 Fév 2013
Do you seriously expect someone go through this? Actually you don't really need to go through all the code in this particular case. It helps if you post a minimum working example, it shows some effort from your part and you might discover what the problem is in the process of condensing it.
Please learn to use the debugger, it will save you tons of time in the future.
doc dbstop
Please read the documentation.
doc ctranspose
The problem should become obvious then.

Connectez-vous pour commenter.

 Réponse acceptée

Jan
Jan le 12 Fév 2013
Modifié(e) : Jan le 12 Fév 2013
Ouch. It is strongly recommended to avoid unnecessary indirections like:
str = strcat(int2str(i),'.jpg');
eval('img=imread(str);');
This is faster, safer, cleaner and less weird:
img = imread(sprintf('%d.jpg', i));
I'd be so happy, if the crude and brute clearing whould vanish from the world of Matlab: clear all, close all, clc. This does not solve any problems, but wastes time and energy for reloading the function from the disk. At least clear variables should replace clear all.
The error message is very clear. In this line:
InImage = reshape(double(InputImage)',irow*icol,1);
the variable InputImage has more than 2 dimensions. Most likely it is a [X x Y x 3] RGB array and you want:
InImage = reshape(permute(double(InputImage), [2,1,3]), irow*icol, 3);
But I assume you will get further problems, when InImage is not a vector anymore, but a RGB matrix. Therefore something like rgb2gray might be useful.

4 commentaires

sudha
sudha le 13 Fév 2013
thank u for ur help..
stil m getting the error in the same line. the error is
??? Error using ==> reshape To RESHAPE the number of elements must not change.
Error in ==> Mio at 167 InImage=reshape(permute(double(InputImage),[2,1,3]),irow*icol,3);
We cannot solve this without seeing your definition for irow and icol. But my educated guess is that you have used size() incorrectly. Read the description of the output arguments of size() more carefully and remember your image is 3 dimensional.
@sudha: Please try to find the relevant part of the code. It is not efficient to let the users of the forum do this for you.
In spite of this, a very short view on your ugly formatted code revealed:
[irow icol] = size(img);
If img is an RGB image, this fails. Better:
[irow, icol, iColor] = size(img);
or
irow = size(img, 1);
icol = size(img, 2);
But I assume your program can simply not handle RGB images, such that there might be a general weakness of the design. Please find out, to which kind of images your code is designed to.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by