How to read the images serially from imageDataStore

3 ビュー (過去 30 日間)
Ambadas Shinde
Ambadas Shinde 2020 年 3 月 31 日
回答済み: TARUN 2025 年 2 月 27 日
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".

回答 (1 件)

TARUN
TARUN 2025 年 2 月 27 日
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:

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by