Add a xlsx file as target to an image
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all, my goal is to find a way to merge a list of images in which i want to associate as a label a xlsx file (made by 2 columns of numerical values), is there any way to do this? Thanks in advance
2 commentaires
Image Analyst
le 29 Juil 2022
A small example would help explain this to us.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Réponses (1)
Saffan
le 14 Sep 2023
Hi Gianluigi,
I understand that you have an XLSX file for each image, with the file name being the same as the image file name. To associate each image with its relevant data, you can create a structure that includes the image file location and the coordinates data extracted from the corresponding XLSX file, as shown in the following code snippet:
% Get a list of image files
imageFiles = dir('Z:/images/*.jpg');
% Get a list of XLSX files
xlsxFiles = dir('Z:/data/*.xlsx');
data = struct(); % Initialize the struct to store image location and coordinates
for i = 1:numel(imageFiles)
imageLocation = fullfile(imageFiles(i).folder, imageFiles(i).name);
xlsxLocation = fullfile(xlsxFiles(i).folder, xlsxFiles(i).name);
coordinates = readmatrix(xlsxLocation);
data(i).imageLocation = imageLocation;
data(i).coordinates = coordinates;
end
You can also consider creating an image datastore to read the images and a custom datastore to read the coordinates from the associated XLSX files. This approach allows for efficient handling of large datasets. Please refer to the following documentation for more information:
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!