Ho can i imread all images in the Path

1 view (last 30 days)
I have this Code for only one image, I want to convert code to imread all images in the path = ('C:\Users\hp\Desktop\New folder (4)\boss_256_0.4\cover')., and second path=
%% Getting the input images
% disp('Provide the main image...')
[img_file1, img_path1] = uigetfile({'*.png'});
img1 = imread([img_path1,img_file1]);

Accepted Answer

Walter Roberson
Walter Roberson on 4 Nov 2022
img_path1 = 'C:\Users\hp\Desktop\New folder (4)\boss_256_0.4\cover';
dinfo = dir( fullfile(img_path1, '*.png') );
filenames = fullfile({dinfo.folder}, {dinfo.name});
numfiles = length(filenames);
results = zeros(numfiles, SomethingAppropriate);
for K = 1 : numfiles
thisfilename = filenames{K};
img1 = imread(thisfilename);
%now process img1
results(K,:) = something appropriate
end
You might also want to start looking at the flows permitted by imageDatastore -- especially in combination with tools such as augmentedImageDatastore which can automatically resize and convert to rgb or grayscale, so that your later code does not need to worry about that.
  1 Comment
abdullah al-dulaimi
abdullah al-dulaimi on 4 Nov 2022
thank you brother, i ask a a new question, check it please mybe you can help me.

Sign in to comment.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!