> Hello all, I am trying to work with a program called mrGray. I find that
> the sample 8 bit image converts from spm format to mrGray format quite
> nicely, but the 16 bit images we have are made into junk by the conversion
> process...does anyone out there have a matlab script for converting 16 bit
> images to 8 bit images? (Of course, I could be on the wrong track...and I
> would, of course, appreciate any suggestions).
This may be some kind of a byte-swapping issue. On some machines, a series
of 16 bit numbers such as [256 257 258] may be represented in memory by the
following binary:
00000001
00000000
00000001
00000001
00000001
00000010
whereas on others, the numbers would be represented by:
00000000
00000001
00000001
00000001
00000010
00000001
The order of the bytes has basically been swapped in each 16 bit number.
Under unix, you may like to try unswapping the bytes of a 16 bit volume using
something like:
dd if=input.img conv=swab of=output.img
Alternatively, you can convert from a 16 to an 8 bit volume by:
spm_imcalc_ui('input.img','output.img','i1',{[],[],spm_type('uint8'),[]});
input.img should be replaced by the name of your 16 bit image.
output.img should be replaced by the name of the 8 bit image to be created.
'i1' is the expression to be evaluated. In this case, the output equals the
input.
spm_type('uint8') returns a numeric code for unsigned 8-bit data.
Best regards,
-John
--
Dr John Ashburner.
Wellcome Department of Cognitive Neurology.
12 Queen Square, London WC1N 3BG, UK.
tel: +44 (0)20 78337491 or +44 (0)20 78373611 x4381
fax: +44 (0)20 78131420
http://www.fil.ion.ucl.ac.uk/~john
mail: [log in to unmask]
|