I am trying to recreate a DICOM file from a jpeg - 2000 file, which actually
generated from a DICOM file(CT - bits allocated 16, bits Stored - 12, High Bit - 11, Row x Col - 512 x 512).
But after applying Window Center and Width, the output image I am getting is not correct compared with orignal DICOM image.
Kindly tell me what the issue is?
From the jp2 file, I am taking the buffer as unsigned short * and following is the code used for creating DICOM file:
Code: Select all
void CreateDicomFile_16Bit(Uint16* buffer)
{
char szImageInstanceUID[512];
m_dfile = new DcmFileFormat();
DcmDataset *dataset = m_dfile->getDataset();
dataset->putAndInsertString(DCM_SOPClassUID, UID_CTImageStorage);
dataset->putAndInsertString(DCM_PatientsName, m_strPatName);
dataset->putAndInsertString(DCM_PatientID, m_strPatID);
dataset->putAndInsertString(DCM_PatientsSex, "M");
dataset->putAndInsertString(DCM_StudyDate, "20080227");
dataset->putAndInsertString(DCM_SeriesDate, "20080227");
dataset->putAndInsertString(DCM_AccessionNumber, m_strAccessionNo);
dataset->putAndInsertString(DCM_Modality, m_strModality);
dataset->putAndInsertString(DCM_BodyPartExamined, "CHEST");
dataset->putAndInsertString(DCM_SeriesNumber, "1001");
dataset->putAndInsertString(DCM_InstanceNumber, "1001");
dataset->putAndInsertString(DCM_PhotometricInterpretation, "MONOCHROME2");
dataset->putAndInsertString(DCM_RescaleIntercept, "-1024");
dataset->putAndInsertString(DCM_RescaleSlope, "1");
dataset->putAndInsertUint16(DCM_Rows, 512);
dataset->putAndInsertUint16(DCM_Columns, 512);
dataset->putAndInsertUint16(DCM_SamplesPerPixel, 1);
dataset->putAndInsertUint16(DCM_BitsAllocated, 16);
dataset->putAndInsertUint16(DCM_HighBit, 11);
dataset->putAndInsertUint16(DCM_PixelRepresentation, 0);
dataset->putAndInsertUint16Array(DCM_PixelData, (const Uint16*)buffer,
512* 512 * 1);
dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL );
m_dfile->saveFile("d:\\myTest_CT", EXS_LittleEndianExplicit);
}
Alvin