Tiff file with signed 32-bit samples
Posted: 2011-12-19T12:19:04-07:00
Hi,
I have in front of me a data set consisting of tiff files containing 32 bit signed integer samples. (I am aware that is an unusual sample type for a tiff file -- the images come in this format from a fancy X-ray detector.) A simple program using Image::Magick has no trouble reading these files and returns correct values for things like the number of columns and rows.
My immediate goal is to identify which pixels contain values that meet a particular criterion.
When I query the contents of specific pixels, it seems as though the signed 32 bit integer is being converted into a 24 bit value that is returned as an RGB triplet. This is trouble because I am losing information -- specifically, the small-valued (on the scale of a 31-bit integer) pixels are returned to me as (0,0,0). Indeed, the only non-zero valued pixels when read this way are the handful of pixels from the detector that were malfunctioning.
Here is the essence of what I have tried so far:
After spending a few hours with the PerlMagick documentation, I am unclear on how to obtain the signed 32 bit number from a pixel. I would be grateful for a suggestion.
Here is an example of one of my images: http://millenia.cars.aps.anl.gov/~ravel ... xample.tif
Thank you in advance,
Bruce
I have in front of me a data set consisting of tiff files containing 32 bit signed integer samples. (I am aware that is an unusual sample type for a tiff file -- the images come in this format from a fancy X-ray detector.) A simple program using Image::Magick has no trouble reading these files and returns correct values for things like the number of columns and rows.
My immediate goal is to identify which pixels contain values that meet a particular criterion.
When I query the contents of specific pixels, it seems as though the signed 32 bit integer is being converted into a 24 bit value that is returned as an RGB triplet. This is trouble because I am losing information -- specifically, the small-valued (on the scale of a 31-bit integer) pixels are returned to me as (0,0,0). Indeed, the only non-zero valued pixels when read this way are the handful of pixels from the detector that were malfunctioning.
Here is the essence of what I have tried so far:
Code: Select all
use Image::Magick;
my $p = Image::Magick->new();
$p->Read(filename=>"image.tif");
print $p->Get('columns'), $/; # correctly returns the width of the image
print $p->Get('pixel[170,88]'), $/; # returns (0,0,0,0), I am expecting a signed 32 bit number evaluating to 19
print $p->Get('pixel[258,91]'), $/; # returns (16,16,16,0), I am expecting 1048575 = 2^20-1 = a value indicating a broken pixel
Here is an example of one of my images: http://millenia.cars.aps.anl.gov/~ravel ... xample.tif
Thank you in advance,
Bruce