readAllImages

Version 1.1.0.0 (5.03 KB) by Phil
Reads all the images in a given directory
128 Downloads
Updated 9 Mar 2015

View License

A simple class that iterates through a given directory and loads all the images. You can either iterate through the images with the getNext() function or load all the images into a cell array with the getAll() function.
obj=readAllImages(DIRNAME) constructs an object to read all images in
the directory DIRNAME. Use it with the getNext method or the
getAll methods to either iterate through the directory and return a
single image at a time, or return all the images within the directory
into a cell array. Multiple directories can be read if DIRNAME is a
cell array of directory names.

The list of extensions used to search for images is contained in the
extName property. This can be overridden either by directly modifying
the property or via the class constructor options.
Setting property returnTypeDouble to true forces all images to be of
type double and over the range 0 to 1.

An example use

%finds the Matlab directory with the the demo images
pth = fileparts(which('cameraman.tif'));
%use the default constructor
ra=readAllImages(pth);
%cycle through all images
while 1
img=ra.getNext();
if isempty(img)
%getNext returns [] when there are no more images.
break;
end
imshow(img)
pause(1)
end

Cite As

Phil (2024). readAllImages (https://www.mathworks.com/matlabcentral/fileexchange/49891-readallimages), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Search Path in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0.0

Updated documentation, added support for multiple directories.

1.0.0.0