Reading images from a loop
Show older comments
I am trying to read images from a folder with a loop, but the's constantly this error:
Error using imread (line 350)
File "C:\Users\Katya\Documents\MATLAB\sunset\uniform\IMG_6806.JPG.jpg" does not exist.
Error in Finale (line 13)
LogoSet(i).sample = imread(s);
There's a code snippet:
srcFiles = dir('C:\Users\Katya\Documents\MATLAB\sunset\uniform\*.jpg');
% folder with source images
counter = num2str(length(srcFiles));
template = struct('sample', []);
LogoSet = repmat(template, counter);
for i = 1 : numel(LogoSet)
s = ['C:\Users\Katya\Documents\MATLAB\sunset\uniform\' srcFiles(i).name '.jpg'];
LogoSet(i).sample = imread(s);
LogoSet(i).sample = rgb2gray(LogoSet(i).sample);
end
Image does exist in a folder but apparently MATLAB does not recognizes it. It executes correctly the file name but still says that it's not there. Tried with defining a folder - also didn't work. Any help will be appreciated
Accepted Answer
More Answers (0)
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!