How to read the images serially from imageDataStore

3 visualizaciones (últimos 30 días)
Ambadas Shinde
Ambadas Shinde el 31 de Mzo. de 2020
Respondida: TARUN el 27 de Feb. de 2025
In the example of Train Deep Learning Network to Classify New Images mentioned in MATLAB Help Documentation, they have mentioned the following
idx = randperm(numel(imdsValidation.Files),4);
to read the any/random four images. How can I read all files serially, present in "imdsValidation.Files".

Respuestas (1)

TARUN
TARUN el 27 de Feb. de 2025
I understand you are interested in reading all the images sequentially from an imageDatastore.
You can achieve this by using a for loop, as demonstrated in the example below:
filePaths = imdsValidation.Files;
numFiles = numel(filePaths);
for i = 1:numel(imdsValidation.Files)
% Get the path of the i-th image
imgPath = imdsValidation.Files{i};
img = imread(imgPath);
imshow(img); % display the image
title(['Image ' num2str(i)]);
This script will iterate over each file in imdsValidation.Files, read the image using imread, and display it using imshow.
You can refer to the following MathWorks documentation for more information:

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by