compressed pixels with defined length field
Moderator: Moderator Team
compressed pixels with defined length field
Found new (sorry think it is again buggy dicom problem with compressed image.
from dcpixel.cc: line 715
/* determine if the pixel data is captured in native (uncompressed) or encapsulated
* (compressed) format. We only derive this information from the length field
* which is set to undefined length for encapsulated data because even in
* compressed transfer syntaxes the Icon Image Sequence may contain an
* uncompressed image.
*/
if (getLengthField() == DCM_UndefinedLength)
but dicom file has DEFINED length for pixel data and, of course, it failed to decode pixels.
i have sent demo dicom (from real modality) to offis mail, thanks.
from dcpixel.cc: line 715
/* determine if the pixel data is captured in native (uncompressed) or encapsulated
* (compressed) format. We only derive this information from the length field
* which is set to undefined length for encapsulated data because even in
* compressed transfer syntaxes the Icon Image Sequence may contain an
* uncompressed image.
*/
if (getLengthField() == DCM_UndefinedLength)
but dicom file has DEFINED length for pixel data and, of course, it failed to decode pixels.
i have sent demo dicom (from real modality) to offis mail, thanks.
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
agree i will inform,
i didn't find how to change VR and lenght outside of library,
setLenghtField is protected member.... and anyway DcmPixelData is loading (and storing after) it as "wrong" class and messing data...
currently solved problem by changing dcpixel.cc
if (getLengthField() == DCM_UndefinedLength || ixferSyn.isEncapsulated())
i know it is very bad solution but at least for dicoms with one PixelData entry it will work fine.
i didn't find how to change VR and lenght outside of library,
setLenghtField is protected member.... and anyway DcmPixelData is loading (and storing after) it as "wrong" class and messing data...
currently solved problem by changing dcpixel.cc
if (getLengthField() == DCM_UndefinedLength || ixferSyn.isEncapsulated())
i know it is very bad solution but at least for dicoms with one PixelData entry it will work fine.
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
Patching the file directly (e.g. using a hex editor) works as described above (change OW to OB and explicit length to undefined length). That means, the internal pixel sequence and item structure is correct. Maybe, the wrong VR and length field has been introduced during the transfer ...
I agree that this is a bad idea. You should at least check that the pixel data element is on the main level of the dataset (i.e. not inside an Icon Image Sequence or the like).i know it is very bad solution but at least for dicoms with one PixelData entry it will work fine.
just for info, at the moment i solved this (NOT DCMTK!) problem by this patch:
dcpixel.cc:718
OFBool isEncapsulatedPixels = OFFalse;
if (inStream.avail()>=4 && ixferSyn.isEncapsulated()) {
Uint16 groupTag = 0xffff;
Uint16 elementTag = 0xffff;
const E_ByteOrder byteOrder = ixferSyn.getByteOrder();
if (byteOrder != EBO_unknown) {
inStream.mark();
inStream.read(&groupTag, 2);
inStream.read(&elementTag, 2);
inStream.putback();
swapIfNecessary(gLocalByteOrder, byteOrder, &groupTag, 2, 2);
swapIfNecessary(gLocalByteOrder, byteOrder, &elementTag, 2, 2);
// tag has been read
DcmTag newTag(groupTag, elementTag);
if (newTag.getXTag() == DCM_Item) {
isEncapsulatedPixels = OFTrue;
}
}
}
/* determine if the pixel data is captured in native (uncompressed) or encapsulated
* (compressed) format. We only derive this information from the length field
* which is set to undefined length for encapsulated data because even in
* compressed transfer syntaxes the Icon Image Sequence may contain an
* uncompressed image.
*/
if (getLengthField() == DCM_UndefinedLength || isEncapsulatedPixels)
......
dcpixel.cc:718
OFBool isEncapsulatedPixels = OFFalse;
if (inStream.avail()>=4 && ixferSyn.isEncapsulated()) {
Uint16 groupTag = 0xffff;
Uint16 elementTag = 0xffff;
const E_ByteOrder byteOrder = ixferSyn.getByteOrder();
if (byteOrder != EBO_unknown) {
inStream.mark();
inStream.read(&groupTag, 2);
inStream.read(&elementTag, 2);
inStream.putback();
swapIfNecessary(gLocalByteOrder, byteOrder, &groupTag, 2, 2);
swapIfNecessary(gLocalByteOrder, byteOrder, &elementTag, 2, 2);
// tag has been read
DcmTag newTag(groupTag, elementTag);
if (newTag.getXTag() == DCM_Item) {
isEncapsulatedPixels = OFTrue;
}
}
}
/* determine if the pixel data is captured in native (uncompressed) or encapsulated
* (compressed) format. We only derive this information from the length field
* which is set to undefined length for encapsulated data because even in
* compressed transfer syntaxes the Icon Image Sequence may contain an
* uncompressed image.
*/
if (getLengthField() == DCM_UndefinedLength || isEncapsulatedPixels)
......
Who is online
Users browsing this forum: No registered users and 1 guest