LibTIFF + Matlab: how to change temporal position
1 次查看(过去 30 天)
显示 更早的评论
Hello, for the first time I am working with some files with *.TIFF and DICOM extensions generated by MeVisLab from some colleagues of mine. It is supposed to be a 4-D data (x,y,z and time).
Before that I used to work with *.hdr files and so far it is being way too different and because of that I am having some problems which I will attempt to describe them here.
So, let's say I have files: Filename.tif and Filename.dcm.
If I write:
[im1,map1] = imread('Filename.tif');
it will result in a two dimensional 'im1' (299x306 uint16), empty 'map1', and an error saying:
Warning: Only the first slice will be read from this image with depth 372.
I tried writing:
[im1,map1] = imread('Filename.tif',1);
But it gives the same results, no temporal positions neither z dimension. Changing 1 to 2 i'll obtain:
Invalid TIFF image index specified.
Using the imfinfo command, I obtain the following:
FileModDate: '26-Nov-2006 11:32:30'
FileSize: 76209780
Format: 'tif'
FormatVersion: []
Width: 306
Height: 299
BitDepth: 16
ColorType: 'grayscale'
FormatSignature: [73 73 42 0]
ByteOrder: 'little-endian'
NewSubFileType: 0
BitsPerSample: 16
Compression: 'Uncompressed'
PhotometricInterpretation: 'BlackIsZero'
StripOffsets: []
SamplesPerPixel: 1
RowsPerStrip: 4.2950e+09
StripByteCounts: []
XResolution: 12.8000
YResolution: 12.8000
ResolutionUnit: 'Centimeter'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: 160
TileLength: 80
TileOffsets: [2976x1 double]
TileByteCounts: [2976x1 double]
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: 132
MinSampleValue: 0
Thresholding: 1
Offset: 76185608
ImageDescription: 'MeVisLab'
Software: 'MFL MeVis File Format Library, TIFF Module'
SampleFormat: 'Unsigned integer'
SMinSampleValue: 0
SMaxSampleValue: 132
ImageDepth: 372
TileDepth: 1
ImageDepth is in fact there, 372 vertical frames are there.. But how can I change this frame? So I went to read and search for answers through Matlab Help, forums, etc, and found out about Tiff command (that uses LibTIFF). Let me be honest, I never used this library before and I don't intend to use that much, I just wanted to plot the signals between temporal positions for all voxels.
However I read the Matlab Help and tried the following:
t = Tiff('Filename.tif','r')
Which returned:
TIFF File: '/etc/Filename.tif'
Mode: 'r'
Current Image Directory: 1
Number Of Tiles: 2976
SubFileType: Tiff.SubFileType.Default
Photometric: Tiff.Photometric.MinIsBlack
ImageLength: 299
ImageWidth: 306
TileWidth: 160
TileLength: 80
BitsPerSample: 16
Compression: Tiff.Compression.None
SampleFormat: Tiff.SampleFormat.UInt
SamplesPerPixel: 1
PlanarConfiguration: Tiff.PlanarConfiguration.Chunky
ImageDescription: MeVisLab
Orientation: Tiff.Orientation.TopLeft
Reading the entire image with:
subimage_one = t.read();
I'll get a 4-D uint 16 subimage_one. Things look better now, but when I check its size, seems that it has size 299*306*1*372. It is weird to having only 1 temporal position. Because of that, I installed MeVisLab and used the same file. There I confirmed that in fact there are more than one temporal position: it has 6 temporal positions so its size should be 299*306*6*372..
Am I doing something wrong or is there any other way to access all data in the file? Even using imread, it seems that I can't access all data and I'm missing the timecourses.
0 个评论
回答(1 个)
John
2011-9-28
Hi Ricardo, I was going to guess that "6 temporal positions" meant that there is 6 image file directories in the TIFF file? When you use the "read" method, only the current image (or IFD) is read in, so one would have to advance to the next IFD in succession to read in all of your "temporal positions". However, if that were the case, then the output of imfinfo would have shown up as a struct array with 6 elements, and it looks like it is only one in your case.
Any chance I could get hold of your file?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!