im=imread('1.stk','Index',3);
??? Error using ==> rtifc
Invalid TIFF image index specified.
Error in ==> readtif at 52
[X, map, details] = rtifc(args);
Error in ==> imread at 430
[X, map] = feval(fmt_s.read, filename, extraArgs{:});
However, the file opens fine with ImageJ, and if I save
it back to another file, the new file can then be read by
MATLAB.
Does this indicate that the original image stack file is
non-conformant to the TIFF standard, or could it be a
problem with MATLAB itself?
(At the moment, I am working round the problem by invoking
ImageJ in command line mode and getting it to run a macro
to 'convert' each image stack that needs to be read. This
is very slow and a horrible kludge.)
Francis
-----------------------------------------------------------------
What version do you have? R2009b has a new Tiff reader function that
you can use instead of imread. But I bet imread will still work if
you call it correctly and have a valid image.
R2009a sadly.
imfinfo('original.stk') gives some strange 'Software' and 'DateTime'
field values:
Filename: [1x59 char]
FileModDate: '21-Mar-2009 09:57:28'
FileSize: 6516203
Format: 'tif'
FormatVersion: []
Width: 696
Height: 520
BitDepth: 16
ColorType: 'grayscale'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubFileType: 0
BitsPerSample: 16
Compression: 'Uncompressed'
PhotometricInterpretation: 'BlackIsZero'
StripOffsets: [104x1 double]
SamplesPerPixel: 1
RowsPerStrip: 5
StripByteCounts: [104x1 double]
XResolution: 72
YResolution: 72
ResolutionUnit: 'Inch'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: 65535
MinSampleValue: 0
Thresholding: 1
Offset: 6515981
Software: 'II*
mc * ^Z ^Z * '
DateTime: ' * ( ' % & ^Z
^Z '
(The ^Z's really are Ctrl-Zs - they caused trn to suspend when I
pasted in the MATLAB output!)
After the file has been through ImageJ, I get this:
>> f=imfinfo('processed.tif');
>> f(1)
ans =
Filename: 'processed.tif'
FileModDate: '08-Nov-2009 14:56:48'
FileSize: 6515924
Format: 'tif'
FormatVersion: []
Width: 696
Height: 520
BitDepth: 16
ColorType: 'grayscale'
FormatSignature: [77 77 42 0]
ByteOrder: 'little-endian'
NewSubFileType: 0
BitsPerSample: 16
Compression: 'Uncompressed'
PhotometricInterpretation: 'BlackIsZero'
StripOffsets: 356
SamplesPerPixel: 1
RowsPerStrip: 520
StripByteCounts: 723840
XResolution: []
YResolution: []
ResolutionUnit: 'None'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: 65535
MinSampleValue: 0
Thresholding: 1
Offset: 8
ImageDescription: [1x61 char]
UnknownTags: [2x1 struct]
So I guess what is happening is that ImageJ is stripping out
the corrupted fields, allowing MATLAB to read the file.
Francis
See my other post. (Actually, the original file was called
'1.stk' - I changed it to 'original.stk' to make the meaning
clearer - not that would make much difference, I imagine.
I also changed the little rectangular symbols, some of which
were undoubtedly Ctrl-Zs, into '^Z'.)
Grateful you're taking a look at this, Steve.
Francis
It wasn't clear to me in your other post whether the output of imfinfo
for the original file was a single structure or a structure array.
What does this return:
numel(imfinfo('original.stdk'))
Ah, good point. This is what I see:
>> f=imfinfo('1.stk');
Warning: The computation of the tag value for "" involves division
by zero. The value has been set to NaN.
>> numel(f)
ans =
1
On the other hand:
>> f=imfinfo('1.tif'); % 1.tif is processed version of 1.tsk
>> numel(f)
ans =
9
Also, I can do im=imread('1.stk') without any errors, but it only
lets me retrieve the first image in the stack, thus:
>> im=imread('1.stk','Index',1);
>> im=imread('1.stk','Index',2);
??? Error using ==> rtifc
Invalid TIFF image index specified.
Error in ==> readtif at 52
[X, map, details] = rtifc(args);
Error in ==> imread at 430
[X, map] = feval(fmt_s.read, filename, extraArgs{:});
Francis
Can you send me the file? If it's less than about 9 MB you can sent it
to me via e-mail.
Sure! It's a bit over 6MB. I'll send it from my other email
account. I appreciate your taking the time to look at this.
Francis
Thanks for sending me the file.
The file is a MetaMorph Stack (STK) file. The multiple images in the
file are not stored in the normal TIFF fashion. Rather, they are stored
using proprietary private tags.
Here is documentation describing how the stack images are stored:
http://support.meta.moleculardevices.com/docs/t10243.pdf
ftp://ftp.meta.moleculardevices.com/support/stack/STK.doc
I found some MATLAB code online that claims to be able to read MetaMorph
Stack files:
http://www.embl.de/~nedelec/misc/
Looks hopeful! I had to change
~isempty(IMG.info) to isfield(IMG, 'info')
to get rid of an error message, but it seems to allow access to
all images in the stack, which is what I needed.
Many thanks for your help. I think you saved me a lot of hassle.
Francis
I am having similar problems in reading tiff files from a stack saved in a combined *.ics (image cytometry standard) / *.ids (image display subsystem) file.
Any advice will be appreciated.
Luis
I am having similar problems in reading tiff files from a stack saved in a combined *.ics (image cytometry standard) / *.ids (image display subsystem) file.