How to read multiple .png images in a loop using MATLAB
조회 수: 11 (최근 30일)
이전 댓글 표시
MD HASIBUR RAHMAN LEMON
2020년 10월 14일
댓글: MD HASIBUR RAHMAN LEMON
2020년 10월 15일
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);
댓글 수: 0
채택된 답변
Mathieu NOE
2020년 10월 14일
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!