For the last few years we've used a snapshot version of DCMTK 3.5.4 in which we "patched" the RLE decoder so that we could correctly read the incorrectly RLE encoded DICOM files.
Recently we have been looking at the latest 3.5.5 snapshots of DCMTK because of the ability to decode only a limited number of frames at a time. This is an important new feature for us since we sometimes need to be able to decode up to 4000+ 512x512 IVUS frames.
However we in order to read the incorrect RLE encoded files we needed to "patch" the decodeFrame(...) function.
In the decodeFrame(...) function we changed
Code: Select all
// copy the decoded stuff over to the buffer here...
// make sure the RLE decoder has produced the right amount of data
if (rledecoder.size() != bytesPerStripe)
{
// error: RLE decoder is finished but has produced insufficient data for this stripe
return EC_CannotChangeRepresentation;
}
into:
Code: Select all
// copy the decoded stuff over to the buffer here...
// make sure the RLE decoder has produced the right amount of data
if (rledecoder.size() != bytesPerStripe)
{
// error: RLE decoder is finished but has produced insufficient data for this stripe
// BEGIN RLE MISSING PIXELS PATCH
if(lastStripe && (rledecoder.size() < bytesPerStripe))
{
if(result==EC_StreamNotifyClient) // stream ended premature ?
{
result = EC_Normal;
}
}
else // orginal code
return EC_CannotChangeRepresentation;
// END RLE MISSING PIXELS PATCH
}
and changed the for-loop at the end of the function from:
Code: Select all
for (pixel = 0; pixel < bytesPerStripe; ++pixel)
{
*pixelPointer = *outputBuffer++;
pixelPointer += offsetBetweenSamples;
}
to:
Code: Select all
// BEGIN RLE MISSING PIXELS PATCH
//copy the pixel data that was decoded
for (pixel = 0; pixel < rledecoder.size(); ++pixel)
{
*pixelPointer = *outputBuffer++;
pixelPointer += offsetBetweenSamples;
}
//and fill the remainder of the image with copies of the last decoded pixel
Uint8 lastPixelValue=*(outputBuffer-1);
for (pixel = rledecoder.size(); pixel < bytesPerStripe; ++pixel)
{
*pixelPointer = lastPixelValue;
pixelPointer += offsetBetweenSamples;
}
// END RLE MISSING PIXELS PATCH
}
Would be possible for you to change the DcmRLECodecDecoder in a similar manner ?
It would be a great help for us if at least the pixels that were decoded can be retrieved from the DicomImage even if the status of the image is not EC_Normal.
This would make it possible for us to use the standard DCMTK snapshot instead of having to patch it locally.
Dr. J. Eggermont, PhD
Division of Image Processing
Department of Radiology
Leiden University Medical Center