I have a bunch of images in a folder and they are indexed. Eg:
01_Cat.jpg
02_Dog.jpg
and so on. Now, I want to read an image, but I don't want to give the full image name. Is it possible to read an image by using wildcards like below
A = imread('01_*.jpg');
B = imread('02_*.jpg');
This is not working. MatLab is taking *
it literally.
I believe the use of wildcards is not supported in imread
, however you can work around it using the dir
function as follows:
A = imread(getfield(dir('01_*.jpg'),'name'));
B = imread(getfield(dir('02_*.jpg'),'name'));