1. Data bit storage (dcm_bitsstored), Data bit allocation (dcm_bitsallocated), data symbol type (dcm_pixelrepresentation), grayscale offset (dcm_rescaleintercept) Relationship to the data value (Dcm_pixeldata) itself:
(1) dcm_bitsallocated is the number of bytes allocated for each pixel, such as a single byte is 8, two bytes is 16 ...., it is best to use the corresponding dcm_bitsallocated data type to read the DICOM data and save it to the computer memory. If dcm_bitsallocated=16, use short or unsigned short type;
(2) Dcm_pixelrepresentation is the storage type of data, 0 for unsigned storage, and 1 for symbolic storage;
(3) In Dicom file, dcm_bitsstored is a valid storage bit in dcm_bitsallocated. If Dcm_pixelrepresentation=1 (signed storage), then dcm_bitsstored's dcm_highbit bit is the sign bit, for example dcm_bitsstored=12 and dcm_highbit=11, Indicates that the highest bit in the valid storage bit (dcm_bitsstored) is the sign bit, when the data represents a range of-2048 (that is, 2^11) ~ 2043 (that is, 2^11-1);
(4) Dcm_rescaleintercept is used to get the output gray value, that is, the dcm_pixeldata value of each pixel plus the results obtained by dcm_rescaleintercept. Like an image with a pixel grayscale of 1024, offset dcm_rescaleintercept=-1024, then the pixel corresponds to the output 1024+ (-1024) = 0;
(5) from (3) and (4), the image stored in the symbol or unsigned can not determine the output of the image of the positive or negative, but by the dcm_rescaleintercept and dcm_pixeldata the result of the addition of the decision. For example, an unsigned stored image, a pixel grayscale of 255, but offset dcm_rescaleintercept=-1024, then output grayscale =255-1024=-769.
2. The use of DCMTK for DICOM label read and write validity issues
(1) If you are able to explicitly use a certain data type, using a specific data type to read and write, the rows and columns of the image are unsigned integers, and their read and write are available putAndInsertUint16:
Wide Delete dataset->remove (dcm_rows);d ataset->putandinsertuint16 (Dcm_rows,row);
(2) If the data type is not clear, but not the image pixel data, such as dcm_rescaleintercept corresponding data is not determined to be float,double or int, available putandinsertstring:
Grayscale offset Delete dataset->remove (dcm_rescaleintercept), sprintf_s (buf, "%f", rescaleintercept);d ataset-> Putandinsertstring (DCM_RESCALEINTERCEPT,BUF);
(3) for image pixel data reading and writing, it is recommended to use Putandinsertuint8array, such as:
Case Bit_stored8s:delete Dataset->remove (dcm_pixeldata);d Ataset->putandinsertuint8array (DCM_PixelData, ( unsigned char*) pdata,isize) break;case bit_stored8u:delete dataset->remove (dcm_pixeldata);d ataset-> Putandinsertuint8array (Dcm_pixeldata, (unsigned char*) pdata,isize); Break;case bit_stored16s:delete dataset->remove (dcm_pixeldata);d Ataset->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);d Ataset->putandinsertuint8array (Dcm_pixeldata, (unsigned char*) pData,isize* 4); Todo_20150721break;case bit_stored32u:delete dataset->remove (dcm_pixeldata);d ataset-> Putandinsertuint8array (Dcm_pixeldata, (unsigned char*) pdata,isize*4); Todo_20150721break;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Understanding of DICOM parameter information and data reading and writing