Borrar filtros
Borrar filtros

ctranspose Transpose on ND array is not defined.

1 visualización (últimos 30 días)
sudha
sudha el 12 de Feb. de 2013
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 comentario
José-Luis
José-Luis el 12 de Feb. de 2013
Editada: José-Luis el 12 de Feb. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 12 de Feb. de 2013
Editada: Jan el 12 de Feb. de 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 comentarios
Jan
Jan el 13 de Feb. de 2013
@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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by