Problem reading 16bit grayscale image

Hello
I have a strange problem when trying to read in a grayscale image of 16bit. So despite the fact that these images are well displayed in some other software I use, when I am trying to load them in Matlab as tiff files a very strange thing occurs.
So the images are read in as uint16 (which is correct). Some values such as the maximum are also detected correctly but the most of the rest values are imported as zeros, which is absolute wrong !
I trying to read them both with imread() and geotiffread() --- as these files are georeferenced images
Do you know what may be the reason for such a problem ?
Thanks in advance

Answers (1)

Sean de Wolski
Sean de Wolski on 11 Oct 2013
Edited: Sean de Wolski on 11 Oct 2013
Perhaps they should be int16's and the values below zero are saturating to zero since they can't be represented as a uint16?
If you could attach an image, that would help.
More per size clarification
It sounds like the file might actually be a BigTIFF file. You could try using the MATLAB interface to LibTIFF to see if it can be read directly from there:
doc tiff
You can also read in just certain tiles at a time.
This blog may interest you as well:

5 Comments

Thank you for your answer but this is not the case ! The data are unsigned 16bit data and I can see this in the metadata file.
The image data are huge (more than 4giga per image) so I can not send them here. However I clipped a very small tile from the image to send it here and when I tried to read it I see that it works normally !!!
So I want to know if there is a limit on data size in the imread() function as this seems to be the problem ! If this is the case do you have any idea how I can overcome it ?
Thank you
Sean de Wolski
Sean de Wolski on 11 Oct 2013
Edited: Sean de Wolski on 11 Oct 2013
See More
Thanks for the tip - I will look into it
Nevertheless this are the metadata I was able to retrieve with imfinfo()
If you see anyhing 'strange' with it let me know ( this is the small tile file)
FileSize: 9579
Format: 'tif'
FormatVersion: []
Width: 57
Height: 53
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: 1
YResolution: 1
ResolutionUnit: 'None'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: 64
TileLength: 64
TileOffsets: 8
TileByteCounts: 8192
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: 65535
MinSampleValue: 0
Thresholding: 1
Offset: 8890
Software: [1x163 char]
SampleFormat: 'Unsigned integer'
ModelPixelScaleTag: [1.2500 1.2500 0]
ModelTiepointTag: [0 0 0 6.9696e+05 4.1508e+06 0]
GeoKeyDirectoryTag: [1x24 double]
GeoAsciiParamsTag: [1x130 char]
This is my large file - with which I have a problem !
FileSize: 3.9159e+09
Format: 'tif'
FormatVersion: []
Width: 36800
Height: 53200
BitDepth: 16
ColorType: 'grayscale'
FormatSignature: [77 77 0 42]
ByteOrder: 'big-endian'
NewSubFileType: 0
BitsPerSample: 16
Compression: 'Uncompressed'
PhotometricInterpretation: 'BlackIsZero'
StripOffsets: [1x53200 double]
SamplesPerPixel: 1
RowsPerStrip: 1
StripByteCounts: [1x53200 double]
XResolution: []
YResolution: []
ResolutionUnit: 'Inch'
Colormap: []
PlanarConfiguration: 'Chunky'
TileWidth: []
TileLength: []
TileOffsets: []
TileByteCounts: []
Orientation: 1
FillOrder: 1
GrayResponseUnit: 0.0100
MaxSampleValue: 65535
MinSampleValue: 0
Thresholding: 1
Offset: 3.9155e+09
ModelTransformationTag: [1.2500 0 0 662500 0 -1.2500 0 4214000 0 0 0 0 0 0 0 1]
GeoKeyDirectoryTag: [1x52 double]
GeoDoubleParamsTag: [0 500000 0.9996 117 0]
GeoAsciiParamsTag: 'Zone utm50N|'
Please attach the actual image file itself.

Sign in to comment.

Asked:

on 11 Oct 2013

Commented:

on 11 Oct 2013

Community Treasure Hunt

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

Start Hunting!