How to perform automatic conversion of matrix dimensions of images in a way that it works for both rgb and grayscale ??
Show older comments
To perform face recognition, i have a train database with some images. The images in train database need to be pre-processed before they are used for comparison with the test image, which is the input image.
This is what i have done :
T = [];
for i = 1 : Train_Number
str = int2str(i);
str = strcat('\',str,'.jpg');
str = strcat(TrainDatabasePath,str);
img = imread(str);
img = rgb2gray(img);
img = imresize(img, [200 180]);
[irow icol] = size(img);
temp = reshape(img',irow*icol,1);
% temp = reshape(permute(double(img), [2,1,3]), irow*icol, 1);
T = [T temp]; % 'T' grows after each turn
end
This works fine when the train database contains only rgb images. But for grayscale images, it gives error related to dimensions.
How can i make it work for both rgb and grayscale ??
2 Comments
Jan
on 15 Feb 2013
Please do not only claim, that there is an error, but post the message and mention the line also. The less we have to guess, the more efficient is an answer. Thanks.
Accepted Answer
More Answers (0)
Categories
Find more on Semantic Segmentation 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!