[Insight-users] Possible bug reading DICOM MONOCHROME1 images with Pixel Padding Value != 2^bits stored-1

Iván Macía imacia at vicomtech.org
Tue Feb 17 06:00:09 EST 2009


Hi,

If ConvertFixGreyLevels() is removed, all MONOCHROME1 images will fail to
display correctly. On the other hand, right now we cannot use gdcm 2.x.
since we use gdcm 1.x via ITK and directly in our DICOM/PACS viewer.

Maybe we could check for the existence of the tag Pixel Padding Value
(0028,0107) and then set a member variable that is either (2^bits stored)-1
(current value used for substraction) or the Pixel Padding Value if it is
present. The other DICOM tag I could think of, and is present in my image is
Largest Image Pixel Value. Both fields hold the value 32767 (instead of
65535).

Then in PixelReadConvert::ConvertFixGreyLevels() we use this value instead
of the current "mask" variable.

uint16_t mask =1;
for (j=0; j<BitsStored-1; j++)
{
  mask = (mask << 1) +1; // will be fff when BitsStored=12
}

uint16_t *deb = (uint16_t *)Raw;
for (i=0; i<RawSize/2; i++)      
{
  *deb = mask - *deb;
  deb++;
}

If you don't find any inconvenience, I could try this approach myself and
see if it works. However, I don’t know if this would work for other
datasets. I could check with our own data. We have several MONOCHROME1
images to try with.

Iván


-----Mensaje original-----
De: Mathieu Malaterre [mailto:mathieu.malaterre at gmail.com] 
Enviado el: martes, 17 de febrero de 2009 10:47
Para: Bill Lorensen
CC: Iván Macía; insight-users at itk.org
Asunto: Re: [Insight-users] Possible bug reading DICOM MONOCHROME1 images
with Pixel Padding Value != 2^bits stored-1

The only reasonable option I can think of, is disconnect the
ConvertFixGreyLevels(). I would make it an option and activate it only
for ITK/GDCM (somewhere in itk::GDCMImageIO).

Comments ?

On Mon, Feb 16, 2009 at 9:28 PM, Bill Lorensen <bill.lorensen at gmail.com>
wrote:
> Mathieu,
>
> Can it be fixed in gdcm 1.x?
>
> Bill
>
> On Mon, Feb 16, 2009 at 10:48 AM, Mathieu Malaterre
> <mathieu.malaterre at gmail.com> wrote:
>> On Mon, Feb 16, 2009 at 1:03 PM, Iván Macía <imacia at vicomtech.org> wrote:
>>> Hi,
>>>
>>>
>>>
>>> I tried to load a DICOM MONOCHROME1 image (MG) and resulting output
values
>>> are outside the range specified in the DICOM fields. The resulting image
is
>>> shown in black with the W/L settings taken from DICOM.
>>>
>>>
>>>
>>> Debugging a bit and getting deep into ITK, it seems like the problem
lies in
>>> the GDCM library in gdcm::PixelReadConvert::ConvertFixGreyLevels() and
the
>>> interpretation of (0028,0120) Pixel Padding Value and (0028,0107)
Largest
>>> Image Pixel Value. For this image, the Largest Image Pixel Value is
32767
>>> and the Pixel Padding Value 32767 (recommended to be 2^16-1 = 65535) but
not
>>> mandatory.
>>>
>>>
>>>
>>> In gdcm::PixelReadConvert::ConvertFixGreyLevels() always pixels are
>>> converted in the form:
>>>
>>>
>>>
>>> value = 65535 - value
>>>
>>>
>>>
>>> which results in pixels above the 5571 - 32767 range for this image.
>>>
>>>
>>>
>>> In my opinion, in this case it should be
>>>
>>>
>>>
>>> value = 32767 - value
>>>
>>>
>>>
>>> which gives the correct values.
>>>
>>>
>>>
>>> I am not totally sure, but the image seems to be following the standard.
>>> Could please someone confirm this?
>>>
>>> We have several of these images and none is loading correctly
>>>
>>>
>>>
>>> I added a new bug entry in Mantis for this
>>>
>>> http://public.kitware.com/Bug/view.php?id=8538
>>
>> Agreed with diagnosis. Thanks for bug report.
>>
>> If you switch to gdcm 2.x (using ITK_USE_SYSTEM_GDCM) this bug will go
away.
>>
>> Thanks,
>> --
>> Mathieu
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>



-- 
Mathieu



More information about the Insight-users mailing list