convert 16 byte signed images to 16 byte unsigned raw data

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

convert 16 byte signed images to 16 byte unsigned raw data

TELLACHE Mohamed
 
Dear subscribers
 
I am a new user in ImageJ world. I use it to read dicom files and
convert them into raw data with file/export command. The dicom files I
use are from ct scans of human bone. The grey levels were related to
bone densities and also to mechanical properties. When dicom files were
converted into raw data, the 16 byte signed files were converted to 16
byte unsigned type. The problem is that I don't know how this conversion
is performed. When I use the raw data with another application (CT2FEM C
code developed to generate finite element from ct scan) I remark that
grey level marked by -30000 was converted to 54000 for example!! It
appear strange for me!!!
 
If anyone knows how it works, I'll be thankful if she/he/them shear with
me their experience.
 
Cordially
 
****************************************************
Mohamed TELLACHE
PhD student
LABORATOIRE D'AERODYNAMIQUE
ET DE BIOMECANIQUE DU MOUVEMENT
http://www.labm.univ-mrs.fr 
Mail : [hidden email]
TEL : +33(0)4 91 26 62 30
FAX : +33(0)4 91 41 16 91
****************************************************
 
Reply | Threaded
Open this post in threaded view
|

Re: convert 16 byte signed images to 16 byte unsigned raw data

Wayne Rasband
What version of ImageJ are you using? Version 1.34e fixed a bug that
caused the
File/Save As/Raw Data command to not work correctly with signed 16-bit
images and stacks.

-wayne

On Sep 27, 2006, at 5:16 AM, TELLACHE Mohamed wrote:

> Dear subscribers
>
> I am a new user in ImageJ world. I use it to read dicom files and
> convert them into raw data with file/export command. The dicom files I
> use are from ct scans of human bone. The grey levels were related to
> bone densities and also to mechanical properties. When dicom files were
> converted into raw data, the 16 byte signed files were converted to 16
> byte unsigned type. The problem is that I don't know how this
> conversion
> is performed. When I use the raw data with another application (CT2FEM
> C
> code developed to generate finite element from ct scan) I remark that
> grey level marked by -30000 was converted to 54000 for example!! It
> appear strange for me!!!
>
> If anyone knows how it works, I'll be thankful if she/he/them shear
> with
> me their experience.
>
> Cordially
>
> ****************************************************
> Mohamed TELLACHE
> PhD student
> LABORATOIRE D'AERODYNAMIQUE
> ET DE BIOMECANIQUE DU MOUVEMENT
> http://www.labm.univ-mrs.fr
> Mail : [hidden email]
> TEL : +33(0)4 91 26 62 30
> FAX : +33(0)4 91 41 16 91
> ****************************************************
>
>
Reply | Threaded
Open this post in threaded view
|

RE : convert 16 byte signed images to 16 byte unsigned raw data

TELLACHE Mohamed
Dear Wayne,

Thanks for your rapid response.
I am using 1.36b version in windows and linux. The problem is that I
want to convert the 16byte signed images to 16byte unsigned ones and I
in the same time know by what kind of transformation it can be done
(mathematical equation if it's possible).

Thanks a lot

Friendly

-----Message d'origine-----
De : ImageJ Interest Group [mailto:[hidden email]] De la part de
Wayne Rasband
Envoyé : mercredi 27 septembre 2006 15:41
À : [hidden email]
Objet : Re: convert 16 byte signed images to 16 byte unsigned raw data

What version of ImageJ are you using? Version 1.34e fixed a bug that
caused the
File/Save As/Raw Data command to not work correctly with signed 16-bit
images and stacks.

-wayne

On Sep 27, 2006, at 5:16 AM, TELLACHE Mohamed wrote:

> Dear subscribers
>
> I am a new user in ImageJ world. I use it to read dicom files and
> convert them into raw data with file/export command. The dicom files I
> use are from ct scans of human bone. The grey levels were related to
> bone densities and also to mechanical properties. When dicom files
were
> converted into raw data, the 16 byte signed files were converted to 16
> byte unsigned type. The problem is that I don't know how this
> conversion
> is performed. When I use the raw data with another application (CT2FEM

> C
> code developed to generate finite element from ct scan) I remark that
> grey level marked by -30000 was converted to 54000 for example!! It
> appear strange for me!!!
>
> If anyone knows how it works, I'll be thankful if she/he/them shear
> with
> me their experience.
>
> Cordially
>
> ****************************************************
> Mohamed TELLACHE
> PhD student
> LABORATOIRE D'AERODYNAMIQUE
> ET DE BIOMECANIQUE DU MOUVEMENT
> http://www.labm.univ-mrs.fr
> Mail : [hidden email]
> TEL : +33(0)4 91 26 62 30
> FAX : +33(0)4 91 41 16 91
> ****************************************************
>
>
Reply | Threaded
Open this post in threaded view
|

Re: RE : convert 16 byte signed images to 16 byte unsigned raw data

dscho
Hi,

On Thu, 28 Sep 2006, TELLACHE Mohamed wrote:

> Thanks for your rapid response.
> I am using 1.36b version in windows and linux. The problem is that I
> want to convert the 16byte signed images to 16byte unsigned ones and I
> in the same time know by what kind of transformation it can be done
> (mathematical equation if it's possible).

I take it you mean 16-bit? (Not byte...)

Easiest way to do it is to use the Bool "AND" operation:

        int unsigned_int = signed_int & 0xffff;

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: RE : convert 16 byte signed images to 16 byte unsigned raw data

Wayne Rasband
In reply to this post by TELLACHE Mohamed
> Thanks for your rapid response.
> I am using 1.36b version in windows and linux. The problem is
> that I want to convert the 16byte signed images to 16byte
> unsigned ones and I in the same time know by what kind of
> transformation it can be done (mathematical equation if it's possible).

You can convert a signed 16-bit image to unsigned 16-bit by converting
it to 32-bit, adding the absolute of the minimum value (assuming the
minimum is less than zero), then converting back to 16-bits. Here is
macro code that does this:

    run("32-bit");
    getStatistics(area, mean, min, max);
    if (min<0)
        run("Add...", "value="+abs(min));
    run("16-bit");

-wayne