We are experiencing a strange issue with OFFIS DCMTK when doing a DICOM Transfer Syntax conversion of a native-encoded DICOM file to JPEG-LS.
We have two different 10-bit grayscale DICOM images (CR images) which are part of the same study and which are apparently identical from the "features" point of view. In fact, both images have these common features:
* Grayscale
* Native TX Syntax (Implicit VR Little Endian)
* Bits allocated = 16
* Bits stored = 10
* High bit = 9
* Rows = 2140
* Columns = 1760
* Rescale Slope = 1
* Rescale Intercept = 0
* Photometric Interpretation = MONOCHROME1
* Value length of Pixel Data = 7532800 (which seems OK)
Nevertheless, for one of the two images the Tx Syntax conversion fails, and the following assert is triggered within CharLS code:
encodstr.h (line 82) --> AppendToBitStream() --> ASSERT(bitpos >=0);
Can you guess why? What could have this single image so "special" and different from the other image (which has the same set of features) which generates problems to OFFIS and/or CharLS?
Here is the code we use for Tx Syntax conversion in this case:
Code: Select all
DcmFileFormat dcmFileFormat;
if (dcmFileFormat.loadFile(aSrcPathName).good()) // Good file?
{
DcmDataset *pDataset = dcmFileFormat.getDataset();
E_TransferSyntax eTxSyntax = EXS_JPEGLSLossy;
DJLSRepresentationParameter repParameters(2, OFFalse);
// Crash happens on the following line!
pDataset->chooseRepresentation(eTxSyntax, &repParameters);
if (pDataset->canWriteXfer(eTxSyntax))
{
dcmFileFormat.saveFile(aDstPathName, eTxSyntax);
}
}
Best regards.