Discussion:
[Oiio-dev] renaming exr channels
Daniel Flood
2016-01-21 07:12:53 UTC
Permalink
Hi folks,

I'm trying to use oiiotool to take an rgb exr, and change the channel names
to some arbitrary value, while preserving compression type and header
metadata.

I tried this, and noticed different results in oiio 1.2 and 1.5. in.exr is
a rgb exr.

oiiotool in.exr --ch "x=R,y=G,z=B" -o out.exr

In 1.2, this creates an empty exr with the correct channel names (ie xyz),
but no image. In 1.5 it creates the image, but the channels are RGB.

Can someone point me in the right direction for this? The reason is
interfacing with external software which expects channel names to
be certain values.

cheers,
Dan
Larry Gritz
2016-01-22 22:33:30 UTC
Permalink
Is it still a problem in 1.6 and/or master?
Post by Daniel Flood
Hi folks,
I'm trying to use oiiotool to take an rgb exr, and change the channel names to some arbitrary value, while preserving compression type and header metadata.
I tried this, and noticed different results in oiio 1.2 and 1.5. in.exr is a rgb exr.
oiiotool in.exr --ch "x=R,y=G,z=B" -o out.exr
In 1.2, this creates an empty exr with the correct channel names (ie xyz), but no image. In 1.5 it creates the image, but the channels are RGB.
Can someone point me in the right direction for this? The reason is interfacing with external software which expects channel names to be certain values.
cheers,
Dan
--
Larry Gritz
***@larrygritz.com
Larry Gritz
2016-01-22 22:42:22 UTC
Permalink
Never mind. I can reproduce this. Hang on...
Post by Larry Gritz
Is it still a problem in 1.6 and/or master?
Post by Daniel Flood
Hi folks,
I'm trying to use oiiotool to take an rgb exr, and change the channel names to some arbitrary value, while preserving compression type and header metadata.
I tried this, and noticed different results in oiio 1.2 and 1.5. in.exr is a rgb exr.
oiiotool in.exr --ch "x=R,y=G,z=B" -o out.exr
In 1.2, this creates an empty exr with the correct channel names (ie xyz), but no image. In 1.5 it creates the image, but the channels are RGB.
Can someone point me in the right direction for this? The reason is interfacing with external software which expects channel names to be certain values.
cheers,
Dan
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
***@larrygritz.com
Larry Gritz
2016-01-22 22:52:24 UTC
Permalink
If you're just renaming channels in order, this works:

oiiotool in.exr --chnames x,y,z -o out.exr

That should get you unstuck. (I don't remember exactly when --chnames was added, sufficiently old versions may lack it.) Meanwhile, I'll look at --ch and see if I can't figure out why that isn't working.

Note, however, that channel names work strangely in OpenEXR. There is no canonical numerical order in exr, other than alphabetical by channel name. But OIIO says that on the app side of an API, RGBAZ always come first, so OIIO will reorder the presentation of channels for you (though not their actual order in the file). So, oddly, if you "oiiotool -info -v out.exr" in the example above, it will report channels "z, x, y". Because it thinks Z is depth, and puts it before "other things it doesn't recognize". So just beware of this, it's saving the file correctly, but your particular choice of channel names is defeating the presentation heuristic that is almost always preferable to alphabetical order.
Post by Larry Gritz
Never mind. I can reproduce this. Hang on...
Post by Larry Gritz
Is it still a problem in 1.6 and/or master?
Post by Daniel Flood
Hi folks,
I'm trying to use oiiotool to take an rgb exr, and change the channel names to some arbitrary value, while preserving compression type and header metadata.
I tried this, and noticed different results in oiio 1.2 and 1.5. in.exr is a rgb exr.
oiiotool in.exr --ch "x=R,y=G,z=B" -o out.exr
In 1.2, this creates an empty exr with the correct channel names (ie xyz), but no image. In 1.5 it creates the image, but the channels are RGB.
Can someone point me in the right direction for this? The reason is interfacing with external software which expects channel names to be certain values.
cheers,
Dan
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
***@larrygritz.com
Larry Gritz
2016-01-22 23:08:40 UTC
Permalink
Aha, I see where it's going wrong. The --ch (and underlying ImageBufAlgo::channels() function) notices when you have requested a channel order that doesn't actually change the ordering, and so takes an "early out" rather than copy channel data all over the place for no good reason. It's failing to notice that you may not be changing the order, but you are changing the names.

I'll prepare a separate fix for that, but in the mean time --chnames is the way to go when you are only renaming channels but not changing their order. (--ch would work for renaming, if only at least one channel has its order changed as well.)

Sorry for the confusion.

-- lg
Post by Larry Gritz
oiiotool in.exr --chnames x,y,z -o out.exr
That should get you unstuck. (I don't remember exactly when --chnames was added, sufficiently old versions may lack it.) Meanwhile, I'll look at --ch and see if I can't figure out why that isn't working.
Note, however, that channel names work strangely in OpenEXR. There is no canonical numerical order in exr, other than alphabetical by channel name. But OIIO says that on the app side of an API, RGBAZ always come first, so OIIO will reorder the presentation of channels for you (though not their actual order in the file). So, oddly, if you "oiiotool -info -v out.exr" in the example above, it will report channels "z, x, y". Because it thinks Z is depth, and puts it before "other things it doesn't recognize". So just beware of this, it's saving the file correctly, but your particular choice of channel names is defeating the presentation heuristic that is almost always preferable to alphabetical order.
Post by Larry Gritz
Never mind. I can reproduce this. Hang on...
Post by Larry Gritz
Is it still a problem in 1.6 and/or master?
Post by Daniel Flood
Hi folks,
I'm trying to use oiiotool to take an rgb exr, and change the channel names to some arbitrary value, while preserving compression type and header metadata.
I tried this, and noticed different results in oiio 1.2 and 1.5. in.exr is a rgb exr.
oiiotool in.exr --ch "x=R,y=G,z=B" -o out.exr
In 1.2, this creates an empty exr with the correct channel names (ie xyz), but no image. In 1.5 it creates the image, but the channels are RGB.
Can someone point me in the right direction for this? The reason is interfacing with external software which expects channel names to be certain values.
cheers,
Dan
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
***@larrygritz.com
Larry Gritz
2016-01-22 23:33:19 UTC
Permalink
Here's the PR that fixes the weirdness with --ch: https://github.com/OpenImageIO/oiio/pull/1326
Post by Larry Gritz
Aha, I see where it's going wrong. The --ch (and underlying ImageBufAlgo::channels() function) notices when you have requested a channel order that doesn't actually change the ordering, and so takes an "early out" rather than copy channel data all over the place for no good reason. It's failing to notice that you may not be changing the order, but you are changing the names.
I'll prepare a separate fix for that, but in the mean time --chnames is the way to go when you are only renaming channels but not changing their order. (--ch would work for renaming, if only at least one channel has its order changed as well.)
Sorry for the confusion.
-- lg
Post by Larry Gritz
oiiotool in.exr --chnames x,y,z -o out.exr
That should get you unstuck. (I don't remember exactly when --chnames was added, sufficiently old versions may lack it.) Meanwhile, I'll look at --ch and see if I can't figure out why that isn't working.
Note, however, that channel names work strangely in OpenEXR. There is no canonical numerical order in exr, other than alphabetical by channel name. But OIIO says that on the app side of an API, RGBAZ always come first, so OIIO will reorder the presentation of channels for you (though not their actual order in the file). So, oddly, if you "oiiotool -info -v out.exr" in the example above, it will report channels "z, x, y". Because it thinks Z is depth, and puts it before "other things it doesn't recognize". So just beware of this, it's saving the file correctly, but your particular choice of channel names is defeating the presentation heuristic that is almost always preferable to alphabetical order.
Post by Larry Gritz
Never mind. I can reproduce this. Hang on...
Post by Larry Gritz
Is it still a problem in 1.6 and/or master?
Post by Daniel Flood
Hi folks,
I'm trying to use oiiotool to take an rgb exr, and change the channel names to some arbitrary value, while preserving compression type and header metadata.
I tried this, and noticed different results in oiio 1.2 and 1.5. in.exr is a rgb exr.
oiiotool in.exr --ch "x=R,y=G,z=B" -o out.exr
In 1.2, this creates an empty exr with the correct channel names (ie xyz), but no image. In 1.5 it creates the image, but the channels are RGB.
Can someone point me in the right direction for this? The reason is interfacing with external software which expects channel names to be certain values.
cheers,
Dan
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
_______________________________________________
Oiio-dev mailing list
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
--
Larry Gritz
***@larrygritz.com

Loading...