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.
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
dpb
2019 年 7 月 12 日
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.
回答 (1 件)
Srivardhan Gadila
2019 年 7 月 17 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!