Hi Everyone,
Looking for some help in converting a multi-chan file to a multi-part file
ultimately, but in the interim was just trying to extract individual
channels from an multi-channel exr and write as individual exrs (using the
python API).

In a nutshell what I have been doing is the following:
Go through each channel in the multi-chan file and figure out what layers
we have (so normals or indirect_lighting etc)
Figure how many individual channels and their what names are under that
layer (so is it "R","G","B" etc)
I then create an ROI based on each of those channels (so our RGBA layer roi
looks like this: xbegin: 0, xend: 2289, ybegin: 0, yend: 953, zbegin: 0,
zend: 1, chbegin: 0, chend: 3, and the subsequent layer would be the same,
but with chbegin: 4, chend: 6)
and then run the following python code in an attempt to try to get the
pixels for the relevant layer and it's channels, and then write it out.

chan_roi_dict = {"rgba":  oiio.ROI(0,2289,0,953, 0,1,0,3), "second_layer":
oiio.ROI(0,2289,0,953, 0,1,4,6)}
multi_chan_exr_buf = oiio.ImageBuf(multi_chan_exr)
temp_pixels = multi_chan_exr_buf.get_pixels(oiio.FLOAT,
chan_roi_dict["second_layer"])
output_spec =  multi_chan_exr_buf.spec()
output _spec.nchannels = 3
output _spec.channelnames = ("R","G","B")
output _spec.set_format(oiio.FLOAT)
oiio.set_roi(output_spec, oiio.ROI(0,2289,0,953, 0,1,0,3))
output_buf = oiio.ImageBuf( output _spec)
output_buf.set_pixels(oiio.ROI.All, temp_pixels)
output_buf.write(output_file)

Does this look to be the correct procedure for getting pixels from a
multi-channel exr and writing them out?
Apologies if it's not clear, I can also try to get an example exr if
required and more complete code.
Thanks
Orion
_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to