MATLAB: How to read & display multiple images from a folder

multiple images

I have 20 TIFF images in MATLAB directory. How can I read them all & show them in different windows i.e. 20 windows for 20 images? I am new to MATLAB & currently using MATLAB & Simulink Release 2009a. After reading the images, how to display them one by one on screen?

Best Answer

Create a datastore by specifying the location of your image files.
location = 'E:\New Folder\*.tif'; % folder in which your images exists
ds = imageDatastore(location) % Creates a datastore for all images in your folder
Loop through the datastore, read and display each image in its own window.
while hasdata(ds)
img = read(ds) ; % read image from datastore
figure, imshow(img); % creates a new window for each image
end
For more information on reading and managing a collection of image files, see: