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.
2 次查看(过去 30 天)
显示 更早的评论
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')
0 个评论
回答(1 个)
Harald
2023-9-14
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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!