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.
显示 更早的评论
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!