ImageDataStore read issue -- works sometimes, sometimes not

8 次查看(过去 30 天)
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);

回答(2 个)

Mahesh Taparia
Mahesh Taparia 2021-2-4
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 个评论
Mark Zarella
Mark Zarella 2021-2-4
编辑:Mark Zarella 2021-2-4
That's what I thought originally as well. But I've confirmed the folder path is correct and that the file formats are supported. The way I did this is by manually running the imread function on the SAME file path and it works fine. And I did this programmatically to ensure the difference wasn't due to manual entry.
Mahesh Taparia
Mahesh Taparia 2021-2-4
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
Steven Lord 2021-2-4
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.

类别

Help CenterFile Exchange 中查找有关 Datastore 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by