I am trying to save RAW image data in new DICOM file. Everything is OK if the transfer syntax is EXS_LittleEndianExplicit (uncompressed data).
But I would like to store data with some lossless compression. I tried it with EXS_JPEGProcess14SV1TransferSyntax, but generated DICOM file is unreadable with DicomWorks viewer (or the image is somehow skewed). Only ezDicom can open it. Is it possible to store RAW image data with some lossless compression at all?
Here is piece of my program. First I store some imortant tags like BitsAllocated,BitsStored,HighBit,PhotometricInterpretation,SamplesPerPixel,Columns,Rows,NumberOfFrames,
PixelRepresentation,PlanarConfiguration,ImagePosition,PixelSpacing and SliceThickness. Then I do following code:
Code: Select all
char uid[100];
dataset->putAndInsertString(DCM_SOPClassUID,UID_SecondaryCaptureImageStorage); dataset->putAndInsertString(DCM_SOPInstanceUID,dcmGenerateUniqueIdentifier(uid,SITE_INSTANCE_UID_ROOT));
dataset->putAndInsertString(DCM_PatientsName,"Joe");
dataset->putAndInsertUint8Array(DCM_PixelData, (Uint8*)data,length);
DJDecoderRegistration::registerCodecs(EDC_photometricInterpretation,EUC_default,EPC_default,OFFalse);
DJEncoderRegistration::registerCodecs(ECC_lossyYCbCr,EUC_default,OFFalse,OFTrue,0,0,0,OFTrue,ESS_444,OFFalse,OFFalse,0,0,0.0,0.0,0,0,0,0,OFTrue,OFFalse,OFFalse,OFFalse,OFTrue);
DJ_RPLossless params(6,0); // codec parameters, we use the defaults
dataset->chooseRepresentation(EXS_JPEGProcess14SV1TransferSyntax, ¶ms);
if (dataset->canWriteXfer(EXS_JPEGProcess14SV1TransferSyntax))
{
// store in lossless JPEG format
dcmHeader.saveFile(saveName,EXS_JPEGProcess14SV1TransferSyntax,EET_ExplicitLength,EGL_recalcGL,EPD_noChange,0,0,OFFalse);
}
DJDecoderRegistration::cleanup();
DJEncoderRegistration::cleanup();
(without compression)
http://www.izelva.cz/dicom/1.dcm
(with compression)
http://www.izelva.cz/dicom/2.dcm
Do you have any advices?
Thanks a lot!
Kuba