Page 1 of 1

Multi-channel EXR support in command-line

Posted: 2019-06-26T07:59:31-07:00
by mortenblaa
I'm trying to extract/use specific channels from a multi-channel EXR, in order to save a specific render pass as a PNG.

Similar questions have been asked before, but they all date back 2 or more years.

I frequently use ImageMagick in a 3D animation pipeline to convert EXR files to other, smaller formats. Specifically using Pixar RenderMan to render the final images. These images most often contain multiple channels that are then composited to form the final image. However, they also include a so-called "beauty" pass, which is the combination of these channels/passes.

I have managed to render out EXR files that simple contains the "rgb" and "a" channels and these are converted to PNG without problems. Without the extra channels/passes, though.

Now, RenderMan technically refers to the "beauty" pass' channel as "Ci", and this seems to confuse ImageMagick, though it is RGB. So "Ci.R" etc. I could rename this to "rgb" instead of "Ci", which works, but breaks other tools like RenderMan's denoiser.

From what I can tell it isn't possible to tell ImageMagick to look for the "Ci" pass and use it as normal RGB.

I should note, that trying to open this image in Photoshop also just shows up black, so ImageMagick is not alone. However, Nuke correctly identifies the right channels. I don't know if the OpenEXR format somehow specifies which channels should be used as RGBA by default.

List of channels that should be present in the first sample file:

Code: Select all

Ci
a
specular_mse
albedo
albedo_var
backward
diffuse
diffuse_mse
forward
mse
normal
normal_var
specular
zfiltered
zfiltered_var
Some sample images...

16-bit EXR straight from render with all passes: https://www.dropbox.com/s/mx9phk5ihox17 ... e.exr?dl=0
16-bit EXR with no AOVs (saved using Pixar "It" tool): https://www.dropbox.com/s/a7ponb8df62ah ... s.exr?dl=0
16-bit EXR after denoising: https://www.dropbox.com/s/xh6herwpnr9vu ... d.exr?dl=0
8-bit PNG of what it should look like: https://www.dropbox.com/s/t930v6zb7blvh ... s.png?dl=0

Code: Select all

Version: ImageMagick 7.0.8-49 Q16 x64 2019-06-08 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC HDRI Modules OpenMP(2.0)
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib

Re: Multi-channel EXR support in command-line

Posted: 2019-06-26T08:21:00-07:00
by snibgo
One ambition for IM V7 was the ability to read, process and write an arbitrary number of channels. But this has not happened.

exiftool can see the names of the many channels in sample_beauty_variance.exr, but has no ability (as far as I know) to rename the channels or to extract pixel data from arbitrary channels.

Re: Multi-channel EXR support in command-line

Posted: 2019-06-26T16:56:26-07:00
by magick
The arbitrary channel infrastructure is in place in version 7 series of ImageMagick. We've been looking for use cases (and time) to add the finishing touches for fully-functional multi-channel image support. For convenience, we utilize the EXR delegate library ImfInputSetFrameBuffer() which only returns 4 channels @ RGBA. We'll need to revisit the EXR coder module to read all the image channels. If you have pointers to some example OpenEXR source code that reads all the channels of an EXR image, post the link here.