View Full Version : Data Type Conversion
psyba
2006.06.06, 01:09 PM
I have some Scientific Textures that are Gray Scale 4 Byte Floats/Pixel ranging from greater then -1 to less then 1. I want to convert them to 2 Byte Shorts ranging from 0 to the Max Short Value. Is there a pre-existing app to do this type of conversion quickly?
Bachus
2006.06.06, 01:30 PM
What format are the scientific images in? Graphic Converter (http://www.lemkesoft.de/en/graphcon.htm) can convert most image types and can do batch convert.
psyba
2006.06.06, 01:49 PM
Format is in
4 Byte Float/Pixel in Raw Format. Floats range from > -1 to < 1.
I need
2 Byte Unsigned Short/Pixel in Raw Format. Unsigned Shorts range from 0 to 0xFFFF.
Zekaric
2006.06.06, 03:08 PM
Sounds like a very trivial thing to write if there isn't a pre-existing tool that already does this.
akb825
2006.06.06, 03:20 PM
Format is in
4 Byte Float/Pixel in Raw Format. Floats range from > -1 to < 1.
I need
2 Byte Unsigned Short/Pixel in Raw Format. Unsigned Shorts range from 0 to 0xFFFF.
That's not what he meant. He's asking if it's in a pre-existing image format that's used (ex: png, tiff, etc., even though those wouldn't fit the description)
This is relatively simple to do on your own.
unsigned short translatePixel(float pixel)
{
//make the pixel go from 0 to 1
pixel = (pixel + 1)/2;
//make the short value
return (unsigned short)roundf(pixel*0xFFFF);
}
psyba
2006.06.06, 04:20 PM
I ended up writing my own (almost finished). I scaled everything to increase the contrast of the image from 0 to 2 to 0 to SHRT_MAX. I vectorized it because it is 3D data consisting of a bunch of slices concatenated together totaling 1.5gigs. The format is EM which is RAW with a header and it can support more types then just float but the particalar data I am using is float. I was just wondering if there was a general pupose utility to do this as it is trivial.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.