How to populate csv rows, rather than columns? This program creates a csv file with each vectorized image in a column, but i want to know if it's possible to store each vectorized image as a row instead.
Show older comments
myDir = 'imgs2';
f = fullfile(myDir, '*.jpg'); % Change to whatever pattern you need.
theFiles = dir(f);
vector_imag = zeros(28^2, length(theFiles ));
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(myDir, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imag = imread(fullFileName); %reads image
imag_gray = rgb2gray(imag); %turns image to grayscale
imag_28 = imresize(imag_gray, [28 28]); %resizes image
vector_imag(:,k) = imag_28(:); %vectorizes the image
end
csvwrite('imgdata.csv', vector_imag); %writes vectorized image to csv file
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type 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!