my purpose is to compress a multiframe object using little memory as possible.
In my test I set the dicom element and 'link' the uncompressed pixel data through DcmPixelData::createValueFromTempFile method, then I choose the representation and save the object in jpeg lossless format. The result is achieved but during the operation the memory size up to the uncompressed pixel data size when was executed the DcmDataset::chooseRepresentation method, this is ok, the documentation is clear but:
Is possible to convert the data without loading all uncompressed frames in memory ?
Thanks in advance
this is the code I used:
Code: Select all
DcmFileFormat fileformat;
DcmDataset *dataset = fileformat.getDataset();
...
dataset->putAndInsertString(DCM_PatientName, "Doe^John");
...
dataset->putAndInsertUint16(DCM_Rows,rows);
dataset->putAndInsertUint16(DCM_Columns,columns);
dataset->putAndInsertUint16(DCM_SamplesPerPixel,samples_per_pixel);
dataset->putAndInsertUint16(DCM_BitsAllocated, bits_allocated);
dataset->putAndInsertUint16(DCM_BitsStored,bits_stored);
...
DcmPixelData *dpix = new DcmPixelData(DCM_PixelData);
dpix->createValueFromTempFile(new DcmInputFileStreamFactory(pix_data_path.c_str(),0), pixel_data_size, EBO_unknown);
dataset->insert(dpix, OFFalse, OFFalse);
...
DJEncoderRegistration::registerCodecs();
E_TransferSyntax Xfer = EXS_JPEGProcess14SV1TransferSyntax;
...
DJ_RPLossless RPLossless((int)SectionValue, (int)PointTransform);
const DcmRepresentationParameter *DcmRepParam = &RPLossless;
...
dataset->chooseRepresentation(Xfer, DcmRepParam);
if (dataset->canWriteXfer(Xfer))
{
...
}
else
{
...
}
fileformat.saveFile(output_file.c_str(), Xfer);
...