I have a folder containing 6 images and i want to display each of them in matlab. the images are saved as image01,image02....image06.
The output of the code is displaying only the first image multiple times. what am i missing??
a = dir('Example\*.png');
b = 'C:\Example\';
for i=1:length(a) %where a is the path to the image folder
fileName = strcat(b,a(i).name);
disp(fileName);% this allows me to see the names in text.
Image = imread('C:\Example/Image01.png');
figure, imshow(Image);
end
This loop works and does tell me the name of each image 1 by 1 using the disp(filename) so its not a syntax error.
Thanks for the help.
Actually, the dir function should return all what you need in order to locate your files properly (and rebuild their respective path too), without declaring an auxiliary variable to hold the target path:
files = dir('C:\...\MyFolder\*.png');
for i = 1:numel(files)
file = files(i);
filename = fullfile(file.folder,file.name);
disp(filename);
img = imread(filename);
figure();
imshow(img);
end