HI,someone plz help
1 view (last 30 days)
Show older comments
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
on 23 Jan 2016
What is the point of the eval? When the same line without the eval would work just as well.
Answers (2)
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
Image Analyst
on 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.
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
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!