HI,someone plz help

2 Ansichten (letzte 30 Tage)
Dhanya Francis
Dhanya Francis am 23 Jan. 2016
Kommentiert: Star Strider am 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 Kommentar
Guillaume
Guillaume am 23 Jan. 2016
What is the point of the eval? When the same line without the eval would work just as well.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Image Analyst
Image Analyst am 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 Kommentare
Image Analyst
Image Analyst am 23 Jan. 2016
Yep, like I said. 387,900 rows in S and 359,160 rows in temp. Different number of rows so you can't stitch them side by side. You can do it vertically if you want with ;
S = [S; temp];
but I don't really know what you want to do because I haven't really gone over your code in your duplicate question in detail.
Dhanya Francis
Dhanya Francis am 23 Jan. 2016
It worked.Thanks alot..Stay blessed :)

Melden Sie sich an, um zu kommentieren.


Star Strider
Star Strider am 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 Kommentare
Dhanya Francis
Dhanya Francis am 23 Jan. 2016
Thank you :)
Star Strider
Star Strider am 23 Jan. 2016
My pleasure.
How did you finally solve your problem?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by