Hi Larry,

(b) is the closest to what I'm trying to do.

Since sending my initial email, I'm now doing this. This keeps RGB in dest_img, and copies G from src_img into new_layer.new_channel

src_img = oiio.ImageInput.open(src_image_file)
dest_img = oiio.ImageInput.open(dest_image_file)

src_data = src_img.read_image()
dest_data = dest_img.read_image()

src_spec = src_img.spec()
dest_spec = dest_img.spec()

src_img.close()
dest_img.close()

width = dest_spec.width
height = dest_spec.height

new_channels = list(dest_spec.channelnames)
new_channels.append("new_layer.new_channel")
copy_channel_indices = [1]

out_data = np.concatenate((dest_data, src_data[:, :, copy_channel_indices]), 
axis=2)

out_img = oiio.ImageOutput.create(dest_image_file)
out_spec = oiio.ImageSpec(width, height, len(new_channels), "float32")
out_spec.channelnames = tuple(new_channels)
out_img.open(dest_image_file, out_spec)

out_img.write_image(out_data)
out_img.close()


Thanks
Hugh

On 14/08/2022 23:02, Larry Gritz wrote:
Hi, Hugh. Can you clarify whether you want to

(a) make a new RGB image R from B but G and B from A?
(b) make a new image with an additional channel, yielding {R, G, B, and New}, where R,G,B came from A and New is the R channel from B?

?


On Aug 8, 2022, at 8:14 AM, Hugh Macdonald <hugh.macdon...@scanlinevfx.com <mailto:hugh.macdon...@scanlinevfx.com>> wrote:

Hey all,


I'm not overly familiar with the OIIO python API, so apologies if this is quite a simple question! I can't find any information online on how to do this with the Python API...

I've got 2 EXRs, both with RGB channels, and I'd like to take the R channel from one of them and put it into another channel in the other.

I've been looking at doing a 2-step process. The first step being to rename the channels in one ImageBuf, and to remove the unneeded channels, and the second being to use ImageBufAlgo.channel_append() to combine the two images together.


This feels like it is unnecessarily 2 steps. Could someone point me at some examples for how to do this in a single step?


I'm sure that this is pretty simple, but all the examples that I can find are for how to do this kind of thing using oiiotool, rather than doing it directly using the API.


Thanks

--
Hugh

_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org <mailto:Oiio-dev@lists.openimageio.org>
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org


--
Larry Gritz
l...@larrygritz.com <mailto:l...@larrygritz.com>






_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

--
Hugh Macdonald
Product Owner, Volumetric Capture
Eyeline Studios
Ext: 4165
www.scanlinevfx.com

_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to