Two things you need to know:
1. Channel indices start at 0, not 1. (Just like array indices in Python.)
2. The ImageBufAlgo.channels() can extract or shuffle the channels, but by
default, the channel names travel along with the channels themselves! Try this:
new_img = ImageBufAlgo.channels(img, channel_ids, newchannelnames=('R',
'G', 'B'))
> On Feb 16, 2022, at 5:38 AM, Tony DUGARD <[email protected]> wrote:
>
> Hi,
>
> I'm currently writing a tool for splitting vray rendered exr into separate
> channels :
> For exemple, I have 6 channels :
> Channel 1 : "R"
> Channel 2 : "G"
> Channel 3 : "B"
> Channel 4 : 'VRaySpecular.R'
> Channel 5 : "VRaySpecular.G"
> Channel 6 : "VRaySpecular.B"
>
> I've successful grouped the channel into a dict :
> channel_dict = {"" : (1, 2, 3), "VRaySpecular": (4, 5, 6)}
>
> With the following code :
> img = ImageBuf(path)
> for key, channel_ids in channel_dict.tems():
> new_img = ImageBufAlgo.channels(img, channel_ids)
> filename, filetype = os.path.splitext(path)
> out_path = filename + "." + key + filetype
> new_img.write(out_path)
>
> The problem i got is that the channel isn't shuffled into the new_img R, G, B
> channel but instead stay in the VRaySpecular.R, VRaySpecular.G, VRaySpecular.B
>
> I don't know how to shuffle the original channel to the RGB channel.
>
> Thanks.
> Tony
>
>
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
[email protected]
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org