imread file does not exist - Unable to read file with multiple images
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying the following code which reads a file containing multiple images -
clc; clear all;
% Specify the filename containing images
filename = 'D:\BMPtoPNG'
% Read all images from the file
images = imread(filename); ......
But the command prompt shows -
Error using imread
File "D:\BMPtoPNG" does not exist.
Please let me know how to solve this error.
4 Kommentare
DGM
am 14 Mär. 2024
Bearbeitet: DGM
am 14 Mär. 2024
That's not how imread() works. If you want to read everything in a directory, you have to read each file individually.
Antworten (2)
Walter Roberson
am 14 Mär. 2024
% Specify the filename containing images
foldername = 'D:\BMPtoPNG';
% Read all images from the file
dinfo = dir(foldername);
dinfo([dinfo.isfolder]) = []; %get rid of all subfolders including . and ..
filenames = fullfile({dinfo.folder}, {dinfo.name});
nfile = numel(filenames);
images = cell(nfile,1);
for K = 1 : nfile
this_image = imread(filenames{K});
images{K} = this_image;
end
%now images is a cell array of image contents
0 Kommentare
Image Analyst
am 14 Mär. 2024
To process a sequence of files in a folder, see code snippets in the FAQ:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!