Clear Filters
Clear Filters

Add a xlsx file as target to an image

3 views (last 30 days)
Gianluigi Mazzaglia
Gianluigi Mazzaglia on 29 Jul 2022
Answered: Saffan on 14 Sep 2023
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 Comments
Gianluigi Mazzaglia
Gianluigi Mazzaglia on 29 Jul 2022
the goal is to train a model which will learn what are the points associated to that images
Image Analyst
Image Analyst on 29 Jul 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:

Sign in to comment.

Answers (1)

Saffan
Saffan on 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!

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!