You can achieve this using MATLAB. Below is a step-by-step guide and sample code to help you accomplish this task:
- Read each image from the folders and convert the image to a grayscale matrix if it isn't already.
% Loop through each person's folder and Loop through each image in the person's folder
% Read the image
img = imread(imgFileName);
% Convert to grayscale if necessary using
img = rgb2gray(img);
- Flatten each image matrix (32x32) into a vector (1024x1).
% Flatten the image matrix to a vector
imgVector = reshape(img, [1024, 1]);
- Store each vector in a larger matrix (1024x200) where each column represents a flattened image.
% Store the vector in the appropriate column
allImagesMatrix(:, imageCounter) = imgVector;
- Loop through each folder and image to process them.
% allImagesMatrix now contains all images as column vectors
disp(size(allImagesMatrix)); % Should display [1024, 200]
For in depth understanding of Flattening, refer to the following documentation:
Hope that helps!