Filter löschen
Filter löschen

To read Image from csv file

21 Ansichten (letzte 30 Tage)
Sara Ejaz
Sara Ejaz am 12 Mär. 2023
Kommentiert: Image Analyst am 20 Mär. 2023
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 Kommentar
DGM am 13 Mär. 2023
Bearbeitet: DGM am 13 Mär. 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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 12 Mär. 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 Kommentare
Sara Ejaz
Sara Ejaz am 20 Mär. 2023
i have a retinal images dataset with 50 diseases i want to classify them.
for this first i want to apply machine learning alogorithm on numeric data which i take from theses images by using imread function.
all this data is converted into column formate.
Image Analyst
Image Analyst am 20 Mär. 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);
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.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by