ImageDataStore read issue -- works sometimes, sometimes not
11 views (last 30 days)
Show older comments
I'm getting the below error when trying to read from an image datastore, manipulate, and write. The strange part is that I can read the file using imread perfectly fine. I'm literally copying the filename from the error message and pasting it into an imread command and it works. Any idea how I can troubleshoot this?
Error using matlab.io.datastore.ImageDatastore/read (line 77)
Unable to read file: <redacted filename>
Error in matlab.io.datastore.FileWritable/writeSerial (line 14)
[data, readInfo] = read(dsCopy);
Error in matlab.io.datastore.FileWritable/writeParallel (line 45)
parfor (ii = 1 : size(files,1), M)
Error in matlab.io.datastore.FileWritable/writeall (line 272)
writeParallel(ds, location, files, nvStruct);
Error in augment_images (line 101)
writeall(subds, [options.Filenames.OutputDir options.Mag],
'FilenameSuffix',suffix,
'OutputFormat',options.Filenames.OutputFormat,
'UseParallel',true);
Caused by:
Error using
matlab.io.datastore.exceptions.decorateCustomFunctionError>generateReadFcnError
(line 103)
Error using ReadFcn @readDatastoreImage for file:
<redacted filename>
Error using imread>get_full_filename (line 564)
Cannot open file "<redacted filename>" for reading.
You might not have read permission.
Error in imread (line 374)
fullname = get_full_filename(filename);
Error in readDatastoreImage (line 12)
data = imread(filename);
0 Comments
Answers (2)
Mahesh Taparia
on 4 Feb 2021
Hi
It seems either the folder path is inappropriate or the files are not in the supported image format. Correct the folder path of the files, it will work.
2 Comments
Mahesh Taparia
on 4 Feb 2021
Hi
Can you upload a sample image from your dataset?
Also let me know, if the below code is working your not.
imds = imageDatastore(fullfile(matlabroot,'toolbox','matlab'),...
'IncludeSubfolders',true,'FileExtensions','.tif','LabelSource','foldernames')
Steven Lord
on 4 Feb 2021
If you try running imread inside a parfor loop rather than at the MATLAB prompt, does it throw an error? I'm wondering if the parallel pool is running the workers on a cluster as a different user that does not have the necessary permissions to access the data files.
0 Comments
See Also
Categories
Find more on Datastore 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!