MATLAB: How to read images one by one

dirnatsortnatsortfilesnatural order sortread imagessort_natsortnat

There is multiple images in a folder, but the name is not in order, for example, 01.jpg, 21.jpg, 41.jpg,……101.jpg. How to read these images successively? Thanks very much.

Best Answer

If you have a cell array of the names, then use that. If you don't know the names, then use dir to read the names from the directory where they are saved. The MATLAB Wiki gives an complete working example of how to do this:
(Just scroll down a little to find the example using dir.)