Filter löschen
Filter löschen

The for loop should take the name from the pictures and put them into an excel file. Excel writes the names from left to right but it should write the names from top to down.

1 Ansicht (letzte 30 Tage)
imageFolderPath = 'C...';
imageNames = {};
imageFiles = dir(fullfile(imageFolderPath, '*.jpg'));
% Schleife zum Lesen der Bilder nacheinander
for i = 1:length(imageFiles)
% Vollständiger Pfad zur aktuellen Bilddatei
currentImagePath = fullfile(imageFolderPath, imageFiles(i).name);
% Lese das Bild
OwnIm = imread(currentImagePath);
OwnImRe = imresize(OwnIm,imageSize(:,1:2));
% Zum Anzeigen des Bildes (optional)
imshow(OwnIm);
% Warte auf eine Tasteneingabe, bevor das nächste Bild geladen wird
pause;
% Füge den Bildnamen zur Liste hinzu
imageNames{end +1} = imageFiles(i).name;
end
T = table(imageNames)
%Pfad zur Excel - Datei
excelFilePath = 'C...';
filename = 'Test.xlsx';
writetable(T,filename, 'Sheet', 1,'Range','A1')

Antworten (1)

Harald
Harald am 14 Sep. 2023
Hi,
the problem likely is that the table contains a row vector of image names.
If you transpose imageNames before creating a table, it should work:
imageNames = imageNames';
T = table(imageNames)
A (preferable) alternative would be to preallocate imageNames as a column vector ahead of the loop:
imageNames = cell(length(imageFiles), 1);
Best wishes,
Harald

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!