Reputation: 263
I seem to be having an issue reading .tif files on Matlab2014a. Whenever I use the imread function to read my image, I get the following output:
Error using rtifc
TIFF library error - 'TIFFReadDirectory: Incorrect count for "SampleFormat".'
Error in readtif (line 48)
[X, map, details] = rtifc(args);
Error in imread (line 415)
[X, map] = feval(fmt_s.read, filename, extraArgs{:});
Error in circles (line 3)
RGB = imread('C:\users\michael\desktop\inkblob12.tif');
I've no idea what the issue is or how to fix it, so any pointers would be greatly appreciated! Many thanks.
EDIT: This is the infinfo output:
Filename: 'C:\users\michael\desktop\inkblob12.tif'
FileModDate: '10-Mar-2015 14:06:40'
FileSize: 159794
Format: 'tif'
FormatVersion: []
Width: 250
Height: 250
BitDepth: 32
ColorType: 'truecolor'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubFileType: 0
BitsPerSample: [8 8 8 8]
Compression: 'LZW'
PhotometricInterpretation: 'RGB'
StripOffsets: [1x21 double]
SamplesPerPixel: 4
RowsPerStrip: 12
StripByteCounts: [1x21 double]
XResolution: 72.0090
YResolution: 72.0090
ResolutionUnit: 'Inch'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: [255 255 255 255]
MinSampleValue: [0 0 0 0]
Thresholding: 1
Offset: 159126
Software: 'Matrox Imaging Library [9.00] ...'
Predictor: 'Horizontal differencing'
ExtraSamples: 2
SampleFormat: {'Unsigned integer' 'Unsigned integer' 'Unsigned integer'}
Upvotes: 0
Views: 1182
Reputation: 7817
The specific issue appears to be because the tag for SampleFormat
is not of a type that the tiff library used can cope with. I suggest you check whether the issue is that this has been changed somehow from your original, working tif to your cropped images. (You might also want to try just using imcrop
or something to make the reduced images in MATLAB directly next time around, avoiding potential incompatibility issues entirely).
Since the content of the tags seems to be really just 'Unsigned integer'
, it might work to simply forcibly retag all the images via MATLAB using the gateway to the LibTiff library routines to match what MATLAB expects:
t = Tiff('inkblob12.tif','a'); % loop over your file names, if this works
t.setTag('SampleFormat',Tiff.SampleFormat.UInt);
t.close();
a
for append should leave whatever content was already there alone.
Upvotes: 1