Inconsistency with findAndGetUint16Array
Moderator: Moderator Team
Inconsistency with findAndGetUint16Array
Hi,
I have an image with Rows=512, Columns=512, BitStored=16, and when calling
Uint16* pixelData16 = nullptr;
unsigned long count = 0;
myImage.findAndGetUint16Array(DCM_PixelData, (const Uint16*&)pixelData16, &count);
count is equal to 524288 instead of 262144.
What is wrong here?
Thanks
I have an image with Rows=512, Columns=512, BitStored=16, and when calling
Uint16* pixelData16 = nullptr;
unsigned long count = 0;
myImage.findAndGetUint16Array(DCM_PixelData, (const Uint16*&)pixelData16, &count);
count is equal to 524288 instead of 262144.
What is wrong here?
Thanks
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Inconsistency with findAndGetUint16Array
Two questions: Which version of the DCMTK did you use? What is the VR of the PixelData element?
Re: Inconsistency with findAndGetUint16Array
dcmtk version is 3.6.5, and DCM_PixelData VR is EVR_OB.
Ok does this mean that I should not look at BitsStored? But only us the VR value? I've been using the BitsStored value for a long time and never had an issue like this. Does this mean the image file is not consistent?
I know, lot of questions...
Thank you!
Ok does this mean that I should not look at BitsStored? But only us the VR value? I've been using the BitsStored value for a long time and never had an issue like this. Does this mean the image file is not consistent?
I know, lot of questions...
Thank you!
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Inconsistency with findAndGetUint16Array
According to the DICOM standard, a value of BitsStored=16 (and BitsAllocated >= 16) is not allowed for PixelData with a VR of "OB" (see PS3.5 Section 8.2). That means, the DICOM dataset is invalid.
Also, DcmItem::findAndGetUint16Array() is not applicable to "OB" data (see API documentation). However, it might also be unexpected to a user of this function that the "count" parameter does not return the number of 16-bit values in the resulting array but the number of 8-bit values (because of VR=OB). I will think about it and come up with a solution.
Also, DcmItem::findAndGetUint16Array() is not applicable to "OB" data (see API documentation). However, it might also be unexpected to a user of this function that the "count" parameter does not return the number of 16-bit values in the resulting array but the number of 8-bit values (because of VR=OB). I will think about it and come up with a solution.
You should use findAndGetUint16Array() only for PixelData with a VR of "OW". BitsStored has nothing to do with this encoding level.Ok does this mean that I should not look at BitsStored? But only us the VR value? I've been using the BitsStored value for a long time and never had an issue like this.
Re: Inconsistency with findAndGetUint16Array
Well, shouldn't findAndGetUint16Array() return an error in this case (when VR is "OB")?
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Inconsistency with findAndGetUint16Array
Well, internally PixelData is managed by a "polymorph OB/OW" class, so there is an implicit conversion between both encodings.
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Inconsistency with findAndGetUint16Array
Could you please check the following patch:
Code: Select all
--- a/dcmdata/libsrc/dcitem.cc
+++ b/dcmdata/libsrc/dcitem.cc
@@ -2555,10 +2555,8 @@ OFCondition DcmItem::findAndGetUint16Array(const DcmTagKey& tagKey,
{
if (status.good())
{
- *count = elem->getNumberOfValues();
- /* AT uses two 16-bit integers per value */
- if (elem->ident() == EVR_AT)
- *count *= 2;
+ /* don't use getNumberOfValues() because of OB/OW for pixel data */
+ *count = elem->getLength() / sizeof(Uint16);
} else
*count = 0;
}
Re: Inconsistency with findAndGetUint16Array
Hi, apologies for the long delay, I only managed to try your patch today for reasons too long to explain.
The patch works correctly with my test case.
Thank you
The patch works correctly with my test case.
Thank you
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Inconsistency with findAndGetUint16Array
Thank you for your feedback. In the meantime, I've committed the required changes and pushed them to the public git repository.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest