Recently, did MatLab made any changes in 'imageDatastore' function ?
Show older comments
Recently, did MatLab made any changes in 'imageDatastore' function ?
I was using the following code:
% Reading Images from Image Database Folder
digitDatasetPath = fullfile(matlabdrive,'New_training_samples_IPM');
imds = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%trainData = table2array(imds);
labelCount = countEachLabel(imds)
img = readimage(imds,1);
size(img)
Previously it was working fine. But since past few days I am getting the following errors:

I am unable to understand this error. Someone please help me. I will be greatfull to you.
Answers (1)
Can you check using the imfinfo function that the .tif file cited in the error message is in fact a valid image file? Do you see a struct with information about the file (like the 'eight.tif' case below) or does it error (like the 'census.mat' case below)?
I = imfinfo('eight.tif')
I = imfinfo('census.mat', 'tif')
13 Comments
Image Analyst
on 4 Aug 2023
And attach your tiff file if you still have problems.
Monalisa Das
on 7 Aug 2023
Steven Lord
on 7 Aug 2023
You haven't showed us the output of imfinfo for that file. Since you said that this only started happening a short time ago (after you created the bfsksample234.tif file, perhaps?) until you show us that it is a valid TIF file I'm going to assume that it's not and that you need to fix the file and/or the process or program that creates the file.
Since you're using MATLAB Online I looked to see if there was any entry in the Bug Reports for imageDatastore for the most recent release. There was one but the error message in that bug report didn't match the one in your message. [And I think that might have been fixed already and so doesn't affect the current release, I'm talking to the author of the bug report to see if it needs to be corrected.]
Monalisa Das
on 7 Aug 2023
Monalisa Das
on 9 Aug 2023
Walter Roberson
on 9 Aug 2023
You did not show the output of imfinfo that was requested.
Monalisa Das
on 10 Aug 2023
Let's try opening the file for reading using the low-level file I/O function and see what the operating system tells you.
locationOfFile = '/MATLAB Drive/New_training_samples_IPM/BFSK/bfsksample10.tif';
[fid, status] = fopen(locationOfFile, 'rb')
If fid is -1 (which I expect) what does status say the OS said was the reason it couldn't open the file?
Walter Roberson
on 10 Aug 2023
With the error showing up on different files each time, and with it not happening on other people's computers, what I would suspect is network problems talking to MATLAB Online.
@Monalisa Das do you have any information about how generally reliable your network connection is?
Monalisa Das
on 10 Aug 2023
Monalisa Das
on 10 Aug 2023
Walter Roberson
on 10 Aug 2023
Getting fid of 3 is perfectly normal for a successful attempt to open the file.
If the opening fails sometimes but works sometimes (as you are observing) and a network file system is involved, then the problem is most often a problem with the network reliability.
Second most common in such circumstances is the possibility that the network drive software is not reliable even when there are no network problems; these days among the "name brand" cloud file systems, that most typically would be a problem with the design of Microsoft OneDrive .
Monalisa Das
on 15 Aug 2023
Categories
Find more on Object Detection 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!


