MATLAB: How to have the code access multiple images automatically

image processing

I have multiple images in a folder, for example 'img1, img2, img3' How can I make my code access those files with specified names automatically? I've been using uigetfile and imread but both require manual input.

Best Answer

you can use the function dir() such as files = dir('*.jpg') which will return the file information for each jpeg into a structure. then a simple for-loop to access files.name (given my example of files) to loop through the jpegs in the folder.