MATLAB Answers

HI,someone plz help

1 view (last 30 days)
Dhanya Francis
Dhanya Francis on 23 Jan 2016
Commented: Star Strider on 23 Jan 2016
Error using horzcat Dimensions of matrices being concatenated are not consistent. Error in facedetection (line 39) S=[S,temp];
[EDIT]: code brought over from duplicate question
for i=1:M
str=strcat('C:\Users\Dhanya Francis\Desktop\Project\',int2str(i),'.jpg');
eval('img=imread(str)');
subplot(ceil(sqrt(M)),ceil(sqrt(M)),i)
imshow(img)
if i==2
title('Training set','fontsize',18)
end
drawnow;
[irow,icol]=size(img);
img(irow,icol) ;
temp=reshape(img,irow*icol,1);
S=horzcat(S,temp);
end
  1 Comment
Guillaume
Guillaume on 23 Jan 2016
What is the point of the eval? When the same line without the eval would work just as well.

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 23 Jan 2016
What does this say
size(s)
size(temp)
Chances are, they don't have the same number of rows in them.
  3 Comments
Dhanya Francis
Dhanya Francis on 23 Jan 2016
It worked.Thanks alot..Stay blessed :)

Sign in to comment.


Star Strider
Star Strider on 23 Jan 2016
I do not know your reason for concatenating your reshaped images. If you want to save them for some other purpose later in your code, I would just save them to a cell array (note the curly brackets ‘{}’:
S{i} = reshape(img,irow*icol,1);
Unless you need them in a matrix (that does not appear to be an option anyway considering their differing sizes), this will allow you to recall each one, and even save ‘S’ to a .mat file if you want, so you can just load them and do not (necessarily) have to repeat the loop each time you run your code.
And as Guillaume mentioned in his Comment, change:
eval('img=imread(str)');
to simply:
img=imread(str);
  2 Comments
Star Strider
Star Strider on 23 Jan 2016
My pleasure.
How did you finally solve your problem?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by