How to read multiple images from a folder where images have names like "3_nouvel-obs_hbhnr300_constructedPdf_Nouvelobs2402PDF.clean.png" , "7_nouvel-obs_hbhnr300_constructedPdf_Nouvelobs2402PDF.clean.png" and so on.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
myfolder='G:\Matlab Code-IIITA\DATASETS\nouvel_obs_2402_clean-1.0\input';
pngfiles=dir(fullfile(myfolder,'\*_nouvel-obs_hbhnr300_constructedPdf_Nouvelobs2402PDF.clean.png'));
%% Also tried this : pngfiles=dir(fullfile(myfolder,'\*png'));
for i = 1:5
img{i} = imread(pngfiles(i).name);
end
Above code is giving error : Tried it on MATLAN R2018a:
I want to read the .png files present in a folder:
Error is
Error using imread>get_full_filename (line 516)
File "100_nouvel-obs_hbhnr300_constructedPdf_Nouvelobs2402PDF.clean.png" does not exist.
Error in imread (line 340)
fullname = get_full_filename(filename);
Error in trial (line 5)
img{i} = imread(pngfiles(i).name);
But when i check for pngfiles(1).name i get the following output.
>> pngfiles(1).name
ans =
'100_nouvel-obs_hbhnr300_constructedPdf_Nouvelobs2402PDF.clean.png'
Why i am not able to read/ perform imshow to display images
1 Kommentar
dpb
am 12 Jul. 2019
I'm suspicious of the second dot in the filename--try renaming the file to something w/o that and see if it won't then work successfully.
Antworten (1)
Srivardhan Gadila
am 17 Jul. 2019
Hi,
The error is due to the input argument provided to the “imread” function. The input “pngfiles(i).name” which is equal to
“100_nouvel-obs_hbhnr300_constructedPdf_Nouvelobs2402PDF.clean.png'’ (for i=1 in your case) is not the complete path of the PNG image file you are trying to load.
It can work only in the following scenarios :
- The files are in the MATLAB’s path
- Or the current working directory contains the files which you are loading.
In all other cases provide the complete path of the image file to the “imread” function’s argument. ('G:\Matlab Code-IIITA\DATASETS\nouvel_obs_2402_clean-1.0\input\100_nouvel-obs_hbhnr300_constructedPdf_Nouvelobs2402PDF.clean.png')
0 Kommentare
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!