DICOM Image from JPEG 2000 file

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
alwittta
Posts: 111
Joined: Wed, 2006-03-15, 08:30

DICOM Image from JPEG 2000 file

#1 Post by alwittta »

Dear friends,

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);
}
Thanks and Regards
Alvin

alwittta
Posts: 111
Joined: Wed, 2006-03-15, 08:30

#2 Post by alwittta »

I am confused, Is this the the problem with decompression of jp2 file to Unsigned short buffer or the DICOM file creation using DCMTK?

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#3 Post by Jörg Riesmeier »

Where did you specify the Window Center and Width? What are the original values for the Image Pixel Module? What exactly are you trying to do ...

Btw, a couple of mandatory data elements are mssing in your DICOM image, e.g. Bits Stored, SOP Instance UID, Series Instance UID and Study Instance UID.

alwittta
Posts: 111
Joined: Wed, 2006-03-15, 08:30

#4 Post by alwittta »

Dear Jörg,

Thanks for the reply.

What I am doing here, first I am converting a CT DICOM file to a jpeg 2000 file. After that, I am trying to recreate DICOM file from this jpeg 2000 file.

I am applying window width and window level on newly created DICOM image but its display is not correct.

Following are the original values of the DICOM CT file's the Image Pixel Module

Code: Select all

Transfer Syntax=1.2.840.10008.1.2.1

Sample Per pixel = 1
Photometric Interpretation = MONOCHROME2
Rows, Columns = 512,512
Pixel spacing=0.390625/0.390625
Bits Allocated = 16
Bits Stored = 12
High bit = 11
Pixel Representation=0
Window Center=40/700
Window Width=120/3200
Rescale Intercept=-1024
Rescale Slope=1

I can able to recreate DICOM file using the following code, but image is not showing proper window width and center values.

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_SOPInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT)); 
	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");

	// DCM_AccessionNumber
	dataset->putAndInsertString(DCM_AccessionNumber, m_strAccessionNo);

	dataset->putAndInsertString(DCM_Modality, "CT");

	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_BitsStored, 12);
   dataset->putAndInsertUint16(DCM_HighBit, 11); 
   dataset->putAndInsertString(DCM_WindowCenter, "40/700"); 
   dataset->putAndInsertString(DCM_WindowWidth, "120/3200"); 
   dataset->putAndInsertString(DCM_PixelSpacing, "0.390625/0.390625");
   
   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);
} 
Kindly tell what the problem is?

Thanks and Regards
Alvin

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#5 Post by Jörg Riesmeier »

How did you create the JPEG2000 compressed DICOM image? Are you sure that the bit depth of the compressed image is still the same? Did you compare the minimum and maximum pixel values of the original, compressed and decompressed DICOM image?

alwittta
Posts: 111
Joined: Wed, 2006-03-15, 08:30

#6 Post by alwittta »

Dear Jörg,

Thanks for the reply.

Following are the values I am giving while the creation of JPEG 2000 compression from DICOM image.

Reversible=no
Precision=8

I am assuming that by bit depth, you mean Precision.

But the minimum and maximum pixel values are different, when I compare with orginal DICOM and in decompressed DICOM.
Orginal DICOM
min = -1024
max = 1791
decompressed DICOM
min = -1024
max = 51664

Thanks and Regards
Alvin

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#7 Post by Jörg Riesmeier »

But the minimum and maximum pixel values are different, when I compare with orginal DICOM and in decompressed DICOM.
Ok, and this explains why the original VOI window is not really appropriate for the decompressed image.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests