[Gate-users] Voxelized phantom and interfile format conversion
Didier Benoit
benoit at imnc.in2p3.fr
Mon Oct 3 19:03:32 CEST 2011
Hi Alex,
I have converted MOBY and others phantoms from 32 bits -> unsigned 16
bits, or 8 bits -> unsigned 16 bits. You can do this with a simple C/C++
code.
In your previous mail, at the point 3, the limit of 'unsigned int' is
not -32768 to 32767 but 0 to 4294967296, and 'int' is -2,147,483,647 to
2,147,483,648.
For your information 'unsigned short' is 0 to 65,536, and 'short' is
-32,767 to 32,768.
In this mail, you'll find a little program in C to convert 8 bits ->
unsigned 16 bits.
When a number in 8 bits is -12, for instance, in unsigned 16 bits is
65524, beware :).
(To compile: just 'make' )
I hope that helps you
Kind Regards,
Didier
On 09/30/2011 12:54 PM, Alex wrote:
> Hello:
>
> 1> I think this question might have been raised before. Nevertheless, I
> still struggle with it. Basically I want to convert the Zubal torso phantom
> (8bit unsigned raw) into the interfile format used by GATE (uint16). Some
> has suggested using MATHLAB, others have suggested xmedcon. The problem
> with xmedcon is that there is o uint16 output option (as far as I know). So
> far, I have converted to signed 16 using xmedcon. I am not familiar with
> MATHLAB but to convert from signed to unsigned 16, is it as simple as type
> casting into unsigned 16 such as below.
>
> intArray = uint16(array);
>
>
>
>
> 2> One can accomplish the same thing with C/C++ by simple static cast?
> (assuming that int is 16 bit for my compiler)
>
> y = (unsigned int) x;
>
>
> 3> Also, naively, since pixel value ranges for signed 16 goes from -32768 to
> 32767 and unsigned from 0 to 65535, can one simply convert by this simple C
> snippet:
>
>
> unsigned int y; // -32768 to 32767
> int x = a; // 0 to 65535
>
> y = (unsigned int) (x + 32768);
>
>
> 4> If simple conversion by type casting is possible, I guess I can bypass
> xmedcon and simply convert directly from 8bit raw data to uint16?
>
> Thanks in advance,
>
> Alex
> ECU Medical Physics Student.
> _______________________________________________
> Gate-users mailing list
> Gate-users at lists.opengatecollaboration.org
> http://lists.opengatecollaboration.org/mailman/listinfo/gate-users
--
----------------------------------------------------------------
Didier BENOIT, GATE Engineer
Imagerie et Modélisation en Neurobiologie et Cancérologie (IMNC)
IMNC – UMR 8165 CNRS – Université Paris 7 – Université Paris 11
Campus d’Orsay
Bâtiment 440
91406 ORSAY Cedex
Tél : (33) 1 69 15 68 76
E-mail : benoit at imnc.in2p3.fr
http://www.imnc.in2p3.fr
----------------------------------------------------------------
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Makefile
URL: <http://lists.opengatecollaboration.org/mailman/private/gate-users/attachments/20111003/0a8cc127/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c
Type: text/x-csrc
Size: 3353 bytes
Desc: not available
URL: <http://lists.opengatecollaboration.org/mailman/private/gate-users/attachments/20111003/0a8cc127/attachment.c>
More information about the Gate-users
mailing list