I have a 16-bit CT scan:
Code: Select all
0028,0100,Bits Allocated=16
0028,0101,Bits Stored=16
0028,0102,High Bit=15
0028,0103,Pixel Representation=1
0028,1050,Window Center=50
0028,1051,Window Width=75
0028,1052,Rescale Intercept=0
0028,1053,Rescale Slope=1
Interpreted as 16bit signed values, this is -958. (Pretty close to -1000, which is air).
I decode this file with the following:
Code: Select all
DcmFileFormat *dfile = new DcmFileFormat();
dfile->read(*m_pInputStream, EXS_Unknown, EGL_withoutGL, DCM_MaxReadLength);
E_TransferSyntax xfer = dfile->getDataset()->getOriginalXfer();
unsigned long opt_compatibilityMode = CIF_MayDetachPixelData | CIF_TakeOverExternalDataset;
m_di = new DicomImage(dfile, xfer, opt_compatibilityMode, 0 /*first frame*/, 0 /* all frames */);
Code: Select all
m_di->getOutputData(&myBuffer[0], myBufferSize, 16, 0);
Now comes the strange part. I try the same with a 12-bit scan:
Code: Select all
0028,0100,Bits Allocated=16
0028,0101,Bits Stored=12
0028,0102,High Bit=11
0028,0103,Pixel Representation=0
0028,0200,Image Location [ret]=32736
0028,1050,Window Center=000035 -0170
0028,1051,Window Width=000050 02700
0028,1052,Rescale Intercept=-01.024000E+03
0028,1053,Rescale Slope=001.000000E+00
After decoding the file with the above code, 001D becomes 01D0. It seems as if the sample values were multiplied by 16 during the 12-bit to 16-bit conversion . If I change the getOutputData call to:
Code: Select all
m_di->getOutputData(&myBuffer[0], myBufferSize, 0, 0);
2^15 was not added as with the first example.
So, my main question is: is there any way to decode various files in a uniform way? What I would really like is to get signed 16-bit values where the rescale intercept & slope have already been applied.
Thanks in advance,
-Martin