Effacer les filtres
Effacer les filtres

How to read multiple .png images in a loop using MATLAB

9 vues (au cours des 30 derniers jours)
MD HASIBUR RAHMAN LEMON
MD HASIBUR RAHMAN LEMON le 14 Oct 2020
I want to display multiple picture with using for loop. Maximum 200 picture need to display. I'm doing my code like this:
numberArray = [];
for i = 1:200
str = int2str(i);
str = strcat('\',str,'.png');
str = strcat('C:\Users\Hasibur Rahman\Documents\MATLAB\ClassWork2_62018040032_哈西\LFPW\trainset', str);
image = imread(str);
numberArray = image;
numberArray = numberArray + image;
figure,imshow(numberArray);
title('Original Image!');
pause(1.5);
end
The first picture came to the display then nothing else comes. Now what i need to do to solve that problem. Thanks in advance.
Error using imread>get_full_filename (line 567)
File "C:\Users\Hasibur Rahman\Documents\MATLAB\ClassWork2_62018040032_哈西\2.png" does not exist.
Error in imread (line 374)
fullname = get_full_filename(filename);
Error in Ques3 (line 6)
im = imread(str);

Réponse acceptée

Mathieu NOE
Mathieu NOE le 14 Oct 2020
hi
see below - just change from tif to png extesion and you should be good !
% select appropriate options below ...
% files = dir('*.tif'); % all tif files in current directory
files = dir('handheld*.tif'); % as example : only tiff files with "handheld" in the filename
% main loop
for ck = 1:length(files)
Filename = files(ck).name;
H{ck} = imread(Filename);
% plot (t=just to check)
figure(ck), imagesc(H{ck});
% insert your own code here
end

Plus de réponses (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by