3
$\begingroup$

I am going to do millions of renderings and want to get around the IO overhead by directly storing the rendering results into Numpy arrays. To store the results into Numpy arrays, I am currently using the Viewer node to access bpy.data.images['Viewer Node'].pixels to store the pixel values. For my application, I need to make sure that each pixel value is NOT quantized to integers of range [0, 255] and then normalized to [0, 1]. Does anyone know if it is possible to access RAW values of each pixel using viewer? Or suggest an analysis method so that I asses that myself.

If people here think that it not possible to get the raw values using the Viewer node, then I need to change my rendering pipeline and store the raw data in OpenEXR files.

Also, I noticed that the image in bpy.data.images['Viewer Node'].pixels is an RGBA image although I have set bpy.context.scene.render.image_settings.color_mode to RGB. Why is that? I'm afraid the pixel values are also in 8-bit not 16-bit or 32-bit. Is there a way to make find out the number of bits used per pixel?

$\endgroup$
  • $\begingroup$ Why not render to tiff or openexr? $\endgroup$ – Bruno Mar 9 '18 at 21:40
  • $\begingroup$ @Bruno Because the IO operation quite slow in such scale. Plus, the operating system cannot handle more than a couple of million meta-data files for these many renderings and I have to write another script to deal with that. So it would be ideal if I can find out that I can get the renderings that I want via Viewer node. $\endgroup$ – Amir Mar 9 '18 at 22:07
  • $\begingroup$ Got it. What about the File Output Node which would give you access to a single file rendering at a time. You would have to read and parse the file format for every frame though... $\endgroup$ – Bruno Mar 9 '18 at 23:05
  • $\begingroup$ I just read the friendly manual. See my answer :) $\endgroup$ – Bruno Mar 9 '18 at 23:12
2
$\begingroup$

The API doc says:

pixels

Image pixels in floating point values

Type: float in [-inf, inf], default 0.0

src: https://docs.blender.org/api/blender_python_api_2_75_1/bpy.types.Image.html#bpy.types.Image

$\endgroup$

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.