Skip to content

Rethink default channel naming, just use R, G, B, A.#1434

Merged
lgritz merged 1 commit intoAcademySoftwareFoundation:masterfrom
lgritz:lg-channames
Jun 15, 2016
Merged

Rethink default channel naming, just use R, G, B, A.#1434
lgritz merged 1 commit intoAcademySoftwareFoundation:masterfrom
lgritz:lg-channames

Conversation

@lgritz
Copy link
Collaborator

@lgritz lgritz commented Jun 15, 2016

In particular, 1-channel images (from formats without channel naming) will now get R, 2-channel images get R, G.

It's not perfect, because it's probably not really "red" and "green." But before, we were setting the default names to "A" and "I","A". Which is probably much much worse, because "A" means alpha, and lots of operations treat alpha as special (such as PNG output dividing all the non-alpha channels by the alpha value!).

This is just for formats that don't actually store channel names in the files. Which is most formats.

@fpsunflower
Copy link
Contributor

How about L and LA ? I think that would match the typical use cases better (unless there is a specific reason to try and be a subset of RGBA).

@fpsunflower
Copy link
Contributor

In other words -- I think the main case to fix is 1 channel images (alpha alone doesn't make sense for sure). I don't think I've ever seen a 2 channel image in the wild - so maybe R,G is just as valid as L,A.

@lgritz
Copy link
Collaborator Author

lgritz commented Jun 15, 2016

As somebody pointed out on the oiio-dev side of this conversation, OpenEXR's DWA compressions actually care about the channel names and only apply the lossy compression to certain named channels. Y would work, but I think L would not.

I agree that 2 channel images are extremely rare, if not virtually extinct in the wild, so maybe it's not worth overthinking that case or forcing it to be consistent with the 1-channel case, punt and go with R, G.

So the leading contenders for one-channel are R and Y.

My best argument for R is that it makes the logic for n channels totally consistent, no special cases for 1-channel.

My best argument for Y is that a one-channel file is almost certainly intended to be grayscale intensity, not "red" per se, and "Y" is already commonly a channel name for grayscale intensity (HSY, YIQ, YCrCb, etc.).

@fpsunflower
Copy link
Contributor

Y and R,G works for me. I like it better than calling the 1 channel case R since expanding to R,0,0 is rarely what you want. You almost always want Y,Y,Y.

@lgritz
Copy link
Collaborator Author

lgritz commented Jun 15, 2016

OK, I'll revise this PR. After sleeping on it, I also like Y better than R for single channel. I'll keep R,G for the rare 2-channel case, because I just don't think there's a better choice.

This PR is just about choosing the default channel names for formats that lack channel names in the file. There are some other channel name-related issues that I'll tackle in separate PRs.

@lgritz
Copy link
Collaborator Author

lgritz commented Jun 15, 2016

Updated patch to use name "Y" for the special case of a single channel in the file.

@rmv
Copy link
Contributor

rmv commented Jun 15, 2016

Second version LGTM

@fpsunflower
Copy link
Contributor

LGTM2

…nnel)

1-channel images (from formats without channel naming) get Y.
2+ channel images get R, G, B, A, channel4, channel5, ...

Before, we were setting the default names to "A" for 1-channel and
"I","A" for 2-channel.  Which is bad because "A" means alpha, and some
operations treat alpha as special (such as PNG output dividing all the
non-alpha channels by the alpha value!).

This is just for formats that don't actually store channel names
in the files. Which is most formats.
@lgritz lgritz merged commit f241ccc into AcademySoftwareFoundation:master Jun 15, 2016
@lgritz lgritz deleted the lg-channames branch June 15, 2016 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants