To read Image from csv file
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
i want to read 700 images and store them in .csv file in only one column formate then show these one column formated images into matlab.
1 commentaire
DGM
le 13 Mar 2023
Modifié(e) : DGM
le 13 Mar 2023
If you want the a rectangular image in a single-column format, then there's no obvious way to describe what the original image geometry was. That information would either need to be in the file header, a separate header file, or simply presumed by some convention.
Given that there probably isn't a good reason to store images as CSV unless it's for sake of compatibility with some other software, then the format required by said software is something that must be known in order to create a compatible file.
So what is the required format?
Réponses (1)
Image Analyst
le 12 Mar 2023
See attached code that puts image values into a CSV file. Adapt as needed.
To process a sequence of files, see the FAQ:
4 commentaires
Image Analyst
le 20 Mar 2023
@Sara Ejaz so I'm guessing you got it solved with my hint and got something like this:
% Process a sequence of PNG images.
filePattern = fullfile(pwd, '*.png');
imds = imageDatastore(filePattern) % Create an image Datastore
% Get all filenames into one cell array. Filenames have the complete path (folder prepended).
allFileNames = imds.Files;
numFiles = numel(imds.Files);
for k = 1 : numel(allFileNames)
% Get this file name.
fullFileName = allFileNames{k};
fprintf('Processing %s\n', fullFileName);
% Now read in image with imread.
rgbImage = imread(fullFileName);
% Split apart into spearate color channels.
[r, g, b] = imsplit(rgbImage);
% Make into column format.
data = [r(:), g(:), b(:)];
% Create output filename for this image's CSV file.
outputFileName = strrep(fullFileName, '.png', '.csv');
% Write out the data.
writematrix(data, outputFileName);
end
If you also need x and y, see how I did it in the attached demo.
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
Voir également
Catégories
En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!