How to convert 16-bit (12-bit) GrayScale Dicom file Image with 16-bit Tif(PNG) file or a memory buffer?
ex)
CxImage::Load("c:\\16bitGraySclae.tif",CXIMAGE_FORMAT_BMP)
char uid[100];
DcmFileFormat fileformat;
DcmDataset *dataset = fileformat.getDataset();
dataset->putAndInsertString(DCM_SOPClassUID, UID_SecondaryCaptureImageStorage);
dataset->putAndInsertString(DCM_SOPInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
//add more tags here~~~~~~
dataset->putAndInsertUint16(DCM_SamplesPerPixel,1);
dataset->putAndInsertString(DCM_PhotometricInterpretation,"MONOCHROME2");
dataset->putAndInsertUint16(DCM_BitsAllocated,16);
dataset->putAndInsertUint16(DCM_BitsStored,16);
dataset->putAndInsertUint16(DCM_HighBit,15);
dataset->putAndInsertUint16(DCM_PixelRepresentation,0);
dataset->putAndInsertUint16(DCM_PlanarConfiguration,0);
dataset->putAndInsertUint16(DCM_Rows,GetHeight());
dataset->putAndInsertUint16(DCM_Columns,GetWidth());
//add more tags here
dataset->putAndInsertUint8Array(DCM_PixelData,(UINT8 *)GetBits(), (GetHeight()*info.dwEffWidth)/4);
// GetBits() <<=CxImage /// info.dwEffWidth <<=CxImage
OFCondition status = fileformat.saveFile("C:\\16bit.dcm", EXS_LittleEndianImplicit,EET_UndefinedLength,EGL_withoutGL);
if (status.bad())
AfxMessageBox("Error: cannot write DICOM file ");
How to convert 16-bit GrayScale Dicom file with 16bit Tif ?
Moderator: Moderator Team
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Who is online
Users browsing this forum: No registered users and 1 guest