DICOM bug
[email protected] Mon, 9 Mar 2009 18:07:09 +0000
| Newsgroups | gmane.comp.video.image-magick.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,.
I think I've found a bug in the DICOM reader. In the current 6.4.9-8,
coders/dcm.c has in sketch form:
unsigned long
index,
...
index=ReadBlobLSBShort(image)
then at line 3487:
if (signed_data == 1)
index-=32767;
then later:
index=1UL*ConstrainColormapIndex(image,index);
pixel.red=1UL*image->colormap[index].red;
pixel.green=1UL*image->colormap[index].green;
pixel.blue=1UL*image->colormap[index].blue;
So if we are reading signed data we subtract 32767 from the colour map
index (an unsigned value). This produces a huge positive value for all
indexes less than 32767, which then gets clipped to 65535 by
ConstrainColormapIndex().
I suggest just removing the "if (signed_data == 1) index-=32767;"
lines. I'm not sure where this functionality should go. Perhaps after
looking up in the colormap?
John