Recently, did MatLab made any changes in 'imageDatastore' function ?

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 = struct with fields:
Filename: '/MATLAB/toolbox/images/imdata/eight.tif' FileModDate: '04-Dec-2000 18:57:57' FileSize: 59640 Format: 'tif' FormatVersion: [] Width: 308 Height: 242 BitDepth: 8 ColorType: 'grayscale' FormatSignature: [73 73 42 0] ByteOrder: 'little-endian' NewSubFileType: 0 BitsPerSample: 8 Compression: 'PackBits' PhotometricInterpretation: 'BlackIsZero' StripOffsets: [8 5443 12081 18862 24940 31857 38760 45691 51990 57729] SamplesPerPixel: 1 RowsPerStrip: 26 StripByteCounts: [5435 6638 6781 6078 6917 6903 6931 6299 5739 1588] XResolution: 72 YResolution: 72 ResolutionUnit: 'Inch' Colormap: [] PlanarConfiguration: 'Chunky' TileWidth: [] TileLength: [] TileOffsets: [] TileByteCounts: [] Orientation: 1 FillOrder: 1 GrayResponseUnit: 0.0100 MaxSampleValue: 255 MinSampleValue: 0 Thresholding: 1 Offset: 59318 ImageDescription: 'Scanned by Steve Eddins, The MathWorks, Inc., 1996'
I = imfinfo('census.mat', 'tif')
Error using imfinfo
census.mat does not seem to have format 'TIF'.

13 Comments

And attach your tiff file if you still have problems.
Actually, I am trying to train a deep learning network, (having a combination of CNN and LSTM), I am getting the following error while running the code:
It is saying that, there is a issue with the image- bfsksample234.tif . But this image is present in the respective folder of Online MatLab drive. Every time I run this code, I am getting this error with different image samples. I am not able to understand the problem. The same code was working properly previously but since last few days, I am getting this error. Someone Please help me with this @Steven Lord @Image Analyst .
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.]
Actually the problem is, I am getting this same error with different images every other time I run this code. Currently I am getting the following error:
As can be seen here, this time error is with bfsksample10.tif . This way every other time I run this code I am getting error with different images. As asked by you I checked using 'imfinfo' . Though it is saying that unable to open file but the file is present in the respective folder. I am faceing this problem since past few days that to with Online MatLab only. I checked it in the MATLAB installed in my friends computer, there I didn't get this error. This error is coming only with online MATLAB. "But this same code in online Matlab was working properly untill 3rd week of July" After 3rd week of July only I am facing this issue. Please help me with this Sir @Steven Lord
@Steven Lord @Image Analyst Sir, please provide a solution for the problem mentioned in the above thread. I will be greatful to you. I am stuck with my project work.
You did not show the output of imfinfo that was requested.
@Walter Roberson sir, I have shown the output of "imfinfo" in my previous thread. For your reference I am attaching the link here:
Every other time I run this code I am getting error with different images. As asked for, I checked using 'imfinfo' . Though it is saying that unable to open file but the file is present in the respective folder. I am faceing this problem since past few days that to with Online MatLab only. I checked it in the MATLAB installed in my friends computer, there I didn't get this error. This error is coming only with online MATLAB. "But this same code in online Matlab was working properly untill 3rd week of July" After 3rd week of July only I am facing this issue.
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')
fid = -1
status = 'Permission denied'
If fid is -1 (which I expect) what does status say the OS said was the reason it couldn't open the file?
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?
@Steven Lord sir, This the I am getting the following error:
Like you said I tried using-
locationOfFile = '/MATLAB Drive/New_training_samples_IPM/BFSK/bfsksample230.tif';
[fid, status] = fopen(locationOfFile, 'rb')
I am getting the following:
But, the image is present in the respective folder in MatLab online drive. I am not able to undestand this problem.
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 .
@Steven Lord @Image Analyst @Walter Roberson Sir, please look at the problem mentioned in my previous thread given in this link:
Every other time I run this code I am getting error with different images. As asked for, I checked using 'imfinfo' . Though it is saying that unable to open file but the file is present in the respective folder. I am faceing this problem since past few days that to with Online MatLab only. I checked it in the MATLAB installed in my friends computer, there I didn't get this error. This error is coming only with online MATLAB. "But this same code in online Matlab was working properly untill 3rd week of July" After 3rd week of July only I am facing this issue. I am stuck with my project work. Please see this matter sir. I think there is some problem with the 'imageDatastore' function of online MATLAB. Because the same code is working properly in my friends computer where MATLAB is installed. I am getting this error repeatedly in online MATLAB only. My internet connection is also fast. No problem with the internet connection. I have checked the following you said previously :
locationOfFile = '/MATLAB Drive/New_training_samples_IPM/BFSK/bfsksample10.tif';
[fid, status] = fopen(locationOfFile, 'rb')
I got the result shown in the following link:
Please help me with this. I will be gratefull to you.

Sign in to comment.

Asked:

on 4 Aug 2023

Commented:

on 15 Aug 2023

Community Treasure Hunt

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

Start Hunting!