# Import displays DICOM images as black rectangles (Mma v. 10)

My problem concerns Mathematica version 10.0.1.0 with OS X 10.9.4, OS X 10.9.5 and it does not occur in Mathematica version 9.0.1.0 (on the same computer and OS).

About 90% of my DICOM images are displayed as black rectangles when I use the Import function directly (giving only the name of the file). However, if I specify to Import only the « Graphics » element from the file, the image is displayed correctly !

Actually, it is easy to test, I could reproduce the problem with the image example in the Mathematica Documentation (see ref/format/DICOM) :

Import["ExampleData/head.dcm.gz"]


gives me a black rectangle only

and with

Import["ExampleData/head.dcm.gz", "Graphics"]


the image is displayed correctly.

Does Anyone have the same behaviour (bug?) with version 10 ?

(Once again, i don’t have this problem with version 9.)

UPDATE

The problem comes from a wrong (or lack of) data normalisation, resulting in some very darkened images (so dark that I thought they were entirely black !).
The responsible for that behaviour seems clearly to be the Image function which does not handle correctly Graphics[Raster[...]] anymore.

Here are some detailed observations :

1/ the "black" rectangle displayed by Import is not all black ! Actually it is the image, but it is highly darkened. :

2/ I have also noticed that the imported image Type is Bit16 and that the ColorSpace is Grayscale whereas in Mathematica 9 it is respectively Byte and RGB ...This is curious, the original data seems indeed to be Bit16 ...

3/ The pixels values in the "black" image correspond to the original data values divided by (2^16 -1).

4/ These pixel values should have been automatically normalized so the maximum value in the original data (=1727) would correspond to the max intensity (= 1) in the image.

Actually, this normalisation is correctly done when I Import the image as a Graphic object :

The function Import seems to check automatically in the data what is the max intensity value (=1727) and the correct dimensions (512x512) to use for the display : these informations are explicitly included in the imported graphic.

5/ Now, if I try to convert the correctly imported graphic to an image using the Image function, the result is the same "black" rectangle I had with the default Import in 1/.

6/ The Image function seems to be the origin of the problem. On my computer, it clearly does not take into account anymore the multiple parameter form of Raster.

Here are some basic examples where I try to convert a simple Graphic[Raster[...]] to an Image Object : the pictures should be identical but it does not work here with my version 10.0.1 (it does work with my version 9)

I am very surprised, it seems the problem is only specific to my computer ?!?! (... no one yet has reported a similar problem.

Are there some general tests/checking I could do to understand why this problem is specific to my computer only ? ( For example I have already checked there is no problem with the dynamic libraries the Mathematica executables are linked to - it seems fine except maybe for libz.1.dylib).

Also I thought that maybe Mathematica 10 is interfering with Mathematica 9 (both versions are installed on my computer and I have no problem with M9). Would that be possible ?

Any hint/idea is welcome.

• The example image imports correctly for me on v10 OS X – mfvonh Sep 23 '14 at 14:41
• This is not specific to your computer; the behavior changed between V10.0.0 and V10.0.1. The switch to grayscale makes sense to me, but I don't know why it doesn't rescale appropriately. ImageAdjust is a useful function. – Brett Champion Oct 11 '14 at 2:29