Can we display 10 bits per rgb in Mathematica? I'm using a quadro card and 30 bit monitor and can get a smooth gradient using Psychtoolbox in matlab. The following Mathematica should produce a bar with 8 shades of gray with 10 bits per color but I only see two, implying 8bits per color. (Stretch the bar across the full width of the screen and you'll see 8 steps if it is using 10 bits per color and 2 steps if it is only using 8).

n = 1024;
start = 512;
end = 519;
Graphics[Table[{GrayLevel[g], Rectangle[{g, 0}, {g + 1/n, .001}]}, {g,
    start 1/1024, end 1/1024, 1/n}]]

I'm interested as I have 16 bit greyscale image data and the staircase effect at low bit depth reduces the ability to interpret the images efficiently without adjusting the window of 256 greys over which the 65535 greys present can be viewed. 1024 greys would be a useful improvement. This has been possible in medical imaging for several years but very expensive (tens of thousands of dollars, i.e. Dome 10MP). Now relatively "cheap" setups (like a \$1k quadro card and \$1k dell u3011 display) are able to do similar so it would be great to be able to achieve the same in Mathematica. I think it is to do with enabling opengl but thats as far as I've got.

  • $\begingroup$ I seriously doubt that this is possible with Mathematica. However, you can always effectively approximate more than 256 levels using dithering. Many programs automatically do this, try e.g. converting a 16-bit grey level image that shows banding to 8 bit in Photoshop. The banding will disappear because it applied dithering during conversion. $\endgroup$
    – Szabolcs
    Oct 16, 2013 at 17:23
  • 1
    $\begingroup$ related mathematica.stackexchange.com/questions/17638/… $\endgroup$
    – george2079
    Oct 16, 2013 at 19:14

2 Answers 2


Dont know how much this helps but if you rasterize your graphic you see you have indeed just two gray values:

                Rectangle[{g, 0}, {g + 1/n, .001}]}, {g, start 1/1024, 
                                                      end 1/1024, 1/n}], 
                     ImagePadding -> False, 
                    PlotRangePadding -> None]]
 Union[Flatten[ImageData[%], 1]]

(* {{0.501961, 0.501961, 0.501961}, {0.505882, 0.505882, 0.505882}} *)

The float values are by the way .. 128/255, 129/255 ..

Now you can build your own raster data with highter precision:

Image[Join @@ 
      Table[Table[(2^16-1)  g, {100}, {100}], {g, start/1024 , 
          end/1024 , 1/1024}] // Transpose, "Bit16"]

Between my eyes and monitor I can't see any difference.. but see what you think.

Edit: the first part of this is irrelevant, as Rasterize is at fault, which you can see If you run the 16 bit image through rasterize it chops it to 8 bit.. Would still like to know if the 16bit raster image is chopped to 8bit for display.

Edit 2:

If we export your graphic to TIFF even with BitDetpth->16 it gets chopped to 8bit, however if you export to EPS you get 8 distinct fill values (3 digit floats, so 1000 grays not 1024), so we see fundamentally the graphics object holds the high precision information.

  • $\begingroup$ I looked at SystemInformation[] and under devices it shows 32 bit color depth (8 per rgb and 8 bits for the alpha channel). If we can get the OS to report 30bit color depth then Mathaematica should use it. With Matlab I had to be in full screen mode. I will try and make the ramp image full screen (I'm not sure how to do that but I'll look) $\endgroup$
    – DrBubbles
    Oct 16, 2013 at 20:07
  • $\begingroup$ One of the OpenGL externsions listed in SystemInformation[] under Devices, Graphics Subsystem: OpenGL is: GL_ARB_texture_rgb10_a2ui but I think these extensions are capabilities of the driver rather than a list of extensions that Mathematica is able to use $\endgroup$
    – DrBubbles
    Oct 16, 2013 at 22:04
  • 1
    $\begingroup$ Full screen didn't help. I did find a tool from NEC that demonstrates the reduced banding effect of 10 bit vs 8 bit (and shows 10 bit is working) necdisplay.com/documents/Software/… $\endgroup$
    – DrBubbles
    Oct 16, 2013 at 22:11

Although the original question asks specifically about the capabilities of Mathematica, I would approach the overall problem slightly different.

I do not have a video card capable of 48 bit color (although Windows has had support for it since Win7). Even if that was the case, other considerations (such as lightning conditions in the room) would prompt me to search for a more robust solution.

If I was to display 1024 levels of information in a system with 8 bits per rgb channel, I would use false color. The palette below not only has a nice and soothing blue tint but it will be appropriate for blue-blood patients.

n = 1024;
start = 1;
end = 1024; img = 
  Graphics[Table[{RGBColor[N@{g^2, Sin[π/2 g]^2, g^(1/2)}], 
     Rectangle[{g, 0}, {g + 1/n, .1}]}, {g, start /n, end /n, 1/n}], 
   ImagePadding -> False, PlotRangePadding -> None], 
  RasterSize -> 1024]
Length@IntegerPart[255 Union[Flatten[ImageData[img], 1]]]

enter image description here



Now, Mathematica claims that it used 1627 colors even though the image is only 1024 pixels wide. Baloney! Saving the image to disk and opening it in Photoshop shows antialiasing at the borders.

The following code shows that the color quantization yields 590 different colors.

bits = Log2[1024];
Length@Union@Table[IntegerPart[255 {g^2, Sin[π/2 g]^2, g^(1/2)}], {g, 0, 1, 1/2^bits}]

A similar calculation with bits=16 (for your source images) yields 760 different colors (that is 9.5 bits).

Assuming that Mathematica can use all of the capabilities of your video card, I would still use false color. With a source image of 16 bits and a monitor of 10 bits per channel, the calculation above yields 3027 colors (that is 11.5 bits). I think that is a more robust solution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.