标签:dicom
1. 数据位存储(DCM_BitsStored)、数据位分配(DCM_BitsAllocated)、数据符号类型(DCM_PixelRepresentation)、灰度偏移(DCM_RescaleIntercept) 和数据值(DCM_PixelData)本身的关系:
(1) DCM_BitsAllocated是给每个像素分配的字节数对应的位数,如单字节就是8,两字节就是16.......,把dicom数据读出来存到计算机内存最好就用相应的DCM_BitsAllocated数据类型,如DCM_BitsAllocated=16的时候,用short或者unsigned short类型;
(2) DCM_PixelRepresentation是数据的存储类型,0代表无符号存储,1代表有符号存储;
(3) 在dicom文件里,DCM_BitsStored是DCM_BitsAllocated中的有效存储位。如果DCM_PixelRepresentation=1(有符号存储),那么DCM_BitsStored的DCM_HighBit位为符号位,比如DCM_BitsStored=12并且DCM_HighBit=11的时候,表示有效存储位(DCM_BitsStored)中的最高位为符号位,此时数据表示范围为-2048(即2^11) ~ 2043(即2^11-1);
(4) DCM_RescaleIntercept用于得到输出灰度值,也就是每个像素的DCM_PixelData值加上DCM_RescaleIntercept得到的结果。如一张图像上一个像素点灰度为1024,偏移DCM_RescaleIntercept=-1024,那么该像素对应输出1024+(-1024)=0;
(5) 由(3)和(4)可知,图像存储的有符号或者无符号不能决定图像的输出灰度的正负,而是由DCM_RescaleIntercept与DCM_PixelData的相加的结果决定。比如无符号存储的图像,某一像素灰度为255,但是偏移DCM_RescaleIntercept=-1024,那么输出灰度=255-1024=-769.
2. 对于使用dcmtk对dicom的标签读写有效性问题
(1) 如果是能够明确用某一数据类型,使用特定数据类型来读写,比如图像的行列都是无符号整型的,他们的读写都可用putAndInsertUint16:
//宽 delete dataset->remove(DCM_Rows); dataset->putAndInsertUint16(DCM_Rows,row); //高 delete dataset->remove(DCM_Columns); dataset->putAndInsertUint16(DCM_Columns,col);
(2)如果是不能明确数据类型的,但不是图像像素数据,如DCM_RescaleIntercept对应的数据不确定是float,double还是int,可用putAndInsertString:
//灰度偏移 delete dataset->remove(DCM_RescaleIntercept); sprintf_s(buf,"%f",rescaleIntercept); dataset->putAndInsertString(DCM_RescaleIntercept,buf);
(3)对于图像像素数据的读写,建议一律使用putAndInsertUint8Array,比如:
case BIT_STORED8S: delete dataset->remove(DCM_PixelData); dataset->putAndInsertUint8Array(DCM_PixelData,(unsigned char*)pData,isize); break; case BIT_STORED8U: delete dataset->remove(DCM_PixelData); dataset->putAndInsertUint8Array(DCM_PixelData,(unsigned char*)pData,isize); break; case BIT_STORED16S: delete dataset->remove(DCM_PixelData); dataset->putAndInsertUint8Array(DCM_PixelData,(unsigned char*)pData,isize*2); break; case BIT_STORED16U: delete dataset->remove(DCM_PixelData); dataset->putAndInsertUint8Array(DCM_PixelData,(unsigned char*)pData,isize*2); break; case BIT_STORED32S: delete dataset->remove(DCM_PixelData); dataset->putAndInsertUint8Array(DCM_PixelData,(unsigned char*)pData,isize*4); //todo_20150721 break; case BIT_STORED32U: delete dataset->remove(DCM_PixelData); dataset->putAndInsertUint8Array(DCM_PixelData,(unsigned char*)pData,isize*4); //todo_20150721 break;
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:dicom
原文地址:http://blog.csdn.net/abcdef8c/article/details/47018623