image signed or unsigned bytes - DICOM
This is a discussion on image signed or unsigned bytes - DICOM ; Hi everybody,
I have made an application to read dicom-datasets.
Now I got some images, where the pixeldata are saved in another mode,
with signed short int (2 Bytes).
Has anyone an idea, how to transform the signed data into ...
-
image signed or unsigned bytes
Hi everybody,
I have made an application to read dicom-datasets.
Now I got some images, where the pixeldata are saved in another mode,
with signed short int (2 Bytes).
Has anyone an idea, how to transform the signed data into an unsigned
data (how to shift the bits?)
For some data, this will help to interpretate it, but it is not the
right way.
Does anyone know the real transformation, to make from signed (two byte
data) a "normal" 2 byte data ?
byte makeSigned(byte low, byte high)
{
ushort us;
short ss;
byte wert;
ss = (short) (low << 8 | high );
ss += 2048;
us = (ushort) ss;
wert = (byte) (us>>4);
// wert += 1024;
return wert;
}
Thanx for any help or sample code to tranform signed pixeldata into
"unsigned byte" values.
Joan Onakida
Onakida@gmx.de
-
Re: image signed or unsigned bytes
On Fri, 29 Apr 2005 19:29:34 +0000, Joan Onakida wrote:
> Hi everybody,
>
> I have made an application to read dicom-datasets.
> Now I got some images, where the pixeldata are saved in another mode,
> with signed short int (2 Bytes).
> Has anyone an idea, how to transform the signed data into an unsigned
> data (how to shift the bits?)
>
> For some data, this will help to interpretate it, but it is not the
> right way.
> Does anyone know the real transformation, to make from signed (two byte
> data) a "normal" 2 byte data ?
>
Very recenly I was presented with the same or a simular situation. If the
phometric interprolation is MONOCHROME1 or MONOCHROME2, the algorithm to
convert 16 bit to 8 bit is generally:
if (x <= c - 0.5 - (w-1)/2), then y = ymin
else if (x > c - 0.5 + (w-1)/2), then y = ymax,
else y = ((x - (c - 0.5)) / (w-1) + 0.5) * (ymax - ymin)+ ymin
where x is the input value, y is an output value with a range from ymin to
ymax, c is Window Center, ymin in most cases will be 0x00 and ymax 0xff.