Skip to content

Color transform unpremult logic changes. #1864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2018

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Feb 4, 2018

After some deep thinking and discussion with people who know more color
than me, I have become convinced that you almost always want to make
sure to un-premultiply colors (i.e. divide by alpha) before doing color
space transformations with OCIO, and then re-multiply by alpha (to get
back to "associated alpha") immediately after the color transformation.

To support this,

  • For the ImageBufAlgo color transformation functions, change the default
    value of the unpremult parameter from false to true.

  • oiiotool --colorconvert and the various --ocio commands will
    also default to doing the unpremult/premult steps, unless a new optional
    modifier is used: :unpremult=0.

  • oiiotool --autocc will do the unpremult/premult steps surrounding any
    automatic color transformations that it does upon input and output.

On the whole, I think this makes the situation less error prone for
casual users. Most oiiotool command lines should just use --autocc and
then not need to worry about any explicit use of --colorconvert or
--unpremult/--premult. For the rare case when more control is needed,
the individual commands and modifiers can be used.

Note that for oiiotool, --autocc is not on by default. If you want
images auto-converted to linear space and ouputs auto-converted from
linear to the desired output space, you need to use --autocc.

@lgritz
Copy link
Collaborator Author

lgritz commented Feb 9, 2018

Updated this PR with a few additions:

  1. The default for now of the oiiotool colorconvert/ociostuff modifier :unpremult= is now 0. Meaning that it preserves the old behavior unless you use :unpremult=1. Some time later (but before a major release), we will change the default.

  2. I've added warnings to oiiotool in cases where it can tell that you have incorrectly double-unpremultiplied.

After some deep thinking and discussion with people who know more color
than me, I have become convinced that you *almost always* want to make
sure to un-premultiply colors (i.e. divide by alpha) before doing color
space transformations with OCIO, and then re-multiply by alpha (to get
back to "associated alpha") immediately after the color transformation.

To support this,

* For the ImageBufAlgo color transformation functions, change the default
  value of the `unpremult` parameter from `false` to `true`.

* `oiiotool --autocc` will do the unpremult/premult steps surrounding any
  automatic color transformations that it does upon input and output.

* `oiiotool --colorconvert` and the various `--ocio` commands now take
  an optional modifier `:unpremult=1` which will cause the conversion to
  be internally bracked by a unpremult/premult step (when you do this,
  you no longer need an explicit --unpremult and --premult on the
  command line).

* oiiotool now issues warnings for cases where it has a good reason to
  think you might be double-unpremulting (for example, if you do both
  --unpremult and follow it by a --colorconvert:unpremult=1).

Later, we'll stage a second part of this where we change the default
value for unpremult= to be 1, so that the modifier is not needed (at which
point you REALLY don't want the explicit --unpremult/--premult, or it will
be wrong).

On the whole, I think this makes the situation less error prone for
casual users. Most oiiotool command lines should just use --autocc and
then not need to worry about any explicit use of `--colorconvert` or
`--unpremult/--premult`. For the rare case when more control is needed,
the individual commands and modifiers can be used.

Note that for oiiotool, `--autocc` is not on by default. If you want
images auto-converted to linear space and ouputs auto-converted from
linear to the desired output space, you need to use `--autocc`.
@lgritz lgritz merged commit 0af3c91 into AcademySoftwareFoundation:master Feb 9, 2018
@lgritz lgritz deleted the lg-cc branch February 10, 2018 02:04
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.

1 participant