Page 1 of 1

DICOM incorrectly converts background color

Posted: 2011-04-25T22:42:34-07:00
by purrquay
I have a number of DICOM files (see this one for an example) that I am converting to PNG format. These files have an alpha channel and a white background. The converted PNG files, on the other hand, have black backgrounds.

Using ImageMagick 6.6.9-6 2011-04-14 Q16, I simply ran "convert 4026778101315.DIC 4026778101315.PNG".
Then I did "identify.exe -verbose " on both files. The DICOM file was reported as having "Background color: white", and the PNG file "Background color: black".

Here is what the above DICOM file looks like. Notice the "TR" in the bottom right, along with the extra bright white tooth surfaces.
Image

And this is what the corresponding PNG file looks like:
Image

Please help. I've tried setting the background colour explicitly, but it has no effect on the resulting PNG image.

Re: DICOM incorrectly converts background color

Posted: 2011-04-26T13:21:36-07:00
by glennrp
The alpha channel seems to be gone before it gets to the
PNG encoder. Converting to TXT or MIFF format also yields an
opaque grayscale image. "identify -verbose *.DIC" says the input
file is opaque grayscale.

The reported background color indeed does change from
white to black, but that seems to be irrelevant. I'll look into
why that happened.

Re: DICOM incorrectly converts background color

Posted: 2011-04-26T15:59:53-07:00
by purrquay
Thanks

Re: DICOM incorrectly converts background color

Posted: 2011-04-26T17:38:37-07:00
by magick
Try this command:
  • convert -define dcm:display-range=reset 4026778101315.DIC 4026778101315.doc
If that fails, you made need a recent patch that will be available in ImageMagick 6.6.9-7 Beta available sometime tomorrow.

Re: DICOM incorrectly converts background color

Posted: 2011-04-26T19:25:22-07:00
by glennrp
The background color issue with PNG grayscale output is fixed in SVN revision 4344 (IM-6.6.9-7).

Re: DICOM incorrectly converts background color

Posted: 2011-04-26T20:30:43-07:00
by purrquay
Damn, you guys are quick!

I'll download and test it out.

Thanks muchly again.

Re: DICOM incorrectly converts background color

Posted: 2011-04-27T04:46:48-07:00
by anthony
If you already have downloaded the SVN version, I suggest you get it again now.

I had a re-organisation of the CLI, as part of some steps for a new type of "convert"-like 'scripting' command (for the furture of IM v7 - name undecided) and it left the SVN beta version in a bad start (draw settings were failling). I learned from this made some backups (for future work) and backed out my change. Basically the change is too radical for IMv6 and it was a mistake to check in work toward that change at this time.

As such I suggest you 'update' or 'checkout' the SVN again now. --- Sorry :?


ASIDE...

AT this point in time I will be concentrating more on simle improvements and bug fixes, as I study 'shells' for programming methodology that may improve CLI and scripting capabilities of IM. IM really could use some more programmers. People who are willing to get go it and give it a try. It is amazing what you can do when you try.

FYI.. there is a new 'Inverse' sparse-color addition. See
http://www.imagemagick.org/Usage/canvas/#inverse

Re: DICOM incorrectly converts background color

Posted: 2011-05-01T19:33:32-07:00
by purrquay
Unfortunately, build 6.6.9-7 still produces the same incorrect result on the sample DICOM image (see the original post) :(

Re: DICOM incorrectly converts background color

Posted: 2011-05-01T19:57:26-07:00
by fmw42
I just downloaded your original image and displayed it in IM 6.6.9.7 Q16 Mac OSX Tiger.

display 4026778101315.DIC

and it has the same dark pattern as your converted image. No other application that I have will even open it.

Re: DICOM incorrectly converts background color

Posted: 2011-05-01T20:06:27-07:00
by purrquay
ImageMagick's own display tool obviously has the same behaviour as the convert tool, since they use the same codec.

Try (X)MedCon instead. Sante DICOM Viewer and mDicom also display it correctly.

Re: DICOM incorrectly converts background color

Posted: 2011-05-02T05:32:37-07:00
by magick
ImageMagick can display / convert the image correctly. Simply add -define dcm:display-range=reset to you command line. Its required to reset the window width encoded within the image.

Re: DICOM incorrectly converts background color

Posted: 2011-05-02T14:53:27-07:00
by purrquay
Thanks. That did the trick.