6
$\begingroup$

A year or so ago, I sent this question to WRI (nb- a former employer of mine) and, as happens with bug-reports-that-arent-bug-reports, it was swallowed into the black hole that is Chambanna.

So- I seek a little help here, on the off chance someone has figured this out.

In short: I need greater than 8-bit-per-pixel/component renders of Graphics3D[].

Basically- it appears that, whatever I try with Rasterize[], the ancient (but still present according to FullOptions[]) ColorOutput option, there is nothing that yields any more than 8-bit values at render-time.

For example, a real-valued texture map. Chock full of values on $[0,1]$.

tmap = RandomReal[{0, 1}, {32, 32}];

A cube w/ texture coördinates-

 vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
 coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 
 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 
 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 
 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, {{0, 0, 
 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}}};

Rendered-

Graphics3D[{Texture[Image[tmap]], 
      Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, 
      Boxed -> False, Lighting -> "Neutral"]

dagnabbit

The resulting rendered image is quantized to 8-bits per component, despite the fact that the texture map is a real-valued array. Here, I'll show you---

First- grab the image data of the Graphics3D render... it is in RGB regardless of what you try to specify via options (here, we'll ask for the data in Real in a desperate, pathetic attempt to get something useful, but it doesn't seem to matter)-

d = ImageData[%, "Real"];

Find all the 'unique' pixel values via DeleteDuplicates[]

DeleteDuplicates[Flatten[d]] // Length

255

So, despite the input and (theoretical) render having many more than 256 levels, the output of the render is quantized.

8 bits/channel are fine for 99% of what the world might need out of a render, most folks don't have displays capable of HDR. BUT- 1) I do (I'm a vision scientist... we like our dynamic range) and 2) more importantly, sometimes I want to calculate 'maps' that are rendered onto objects that contain more than 8-bits of information per channel.

Note that the above still applies if you use the illumination model provided in Graphics3D -or- if you set Lighting->None and use Glow[] primitives. Whatever you do, Mathematica quantizes the render.

I've fooled around with various Rasterize[], Show[], and DisplayFunction manipulations with no success. Regardless, my resulting ImageData[] remains quantized.

Any thoughts?

edit/NB- This 8-bit constraint appears to be present in many (all?) routines that create graphics. For example, an ArrayPlot of the texture map quantizes the values (as I'd assume this is what the FE 'needs' to render?)

$\endgroup$
2
$\begingroup$

Mathematica doesn't actually render the graphics. It sends them to a system library that renders them. We can see this effect clearly by rendering glyphs:

Image[Rasterize["0"], Magnification -> 16]

Results in:

enter image description here

Even though this letter should be entirely black, it has a variety of colors present in the magnified image. This is an effect of ClearType: a Windows feature, not a Mathematica one.

Your textured cube is being rendered by your operating system's libraries as an 8-bit image, and that is what Mathematica is getting back to play with. I don't know of any way to get full-depth images from Rasterize.

$\endgroup$
  • $\begingroup$ Of course things are being rendered at the 'operating system's libraries' at some point. The fact remains that, whatever Mathematica is using (OpenGL most likely) -has- the capability of greater bit-depth in its output images (just as it would be possible to turn off the ClearType rendering). It's just not clear if one can access it. For several versions, the image processing package was handled via separate binaries in the MMa package (it may still be like this) that were independent of the OS. $\endgroup$ – flip Apr 28 '15 at 13:46

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.