Skip to content

Commit

Permalink
raw: fix ProPhoto gamma, add ProPoto-linear (#3153)
Browse files Browse the repository at this point in the history
When requesting that raw image be returned as "ProPhoto" color space,
we were using the wrong gamma. Also, at user request, add
"ProPhoto-linear", which is the same but with linear response. (This
is analogous to the existing "sRGB" and "sRGB-linear".)

Fixes #3152
  • Loading branch information
lgritz committed Oct 28, 2021
1 parent 6da6cd9 commit fa26dab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/doc/builtinplugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1514,9 +1514,9 @@ options are supported:
- string
- Which color primaries to use for the returned pixel values: ``raw``,
``sRGB``, ``sRGB-linear`` (sRGB primaries, but a linear transfer
function), ``Adobe``, ``Wide``, ``ProPhoto``, ``XYZ``, ``ACES`` (only
supported by LibRaw >= 0.18), ``DCI-P3`` (LibRaw >= 0.21), ``Rec2020``
(LibRaw >= 0.2). (Default: ``sRGB``)
function), ``Adobe``, ``Wide``, ``ProPhoto``, ``ProPhoto-linear``,
``XYZ``, ``ACES`` (only supported by LibRaw >= 0.18), ``DCI-P3``
(LibRaw >= 0.21), ``Rec2020`` (LibRaw >= 0.2). (Default: ``sRGB``)
* - ``raw:Exposure``
- float
- Amount of exposure before de-mosaicing, from 0.25 (2 stop darken) to
Expand Down
19 changes: 12 additions & 7 deletions src/raw.imageio/rawinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,12 @@ RawInput::open_raw(bool unpack, const std::string& name,
m_processor->imgdata.params.output_color = 1;
m_processor->imgdata.params.gamm[0] = 1.0 / 2.4;
m_processor->imgdata.params.gamm[1] = 12.92;
} else if (Strutil::iequals(cs, "sRGB-linear")
|| Strutil::iequals(cs, "linear") /* DEPRECATED */) {
// Request "sRGB" primaries, linear reponse
m_processor->imgdata.params.output_color = 1;
m_processor->imgdata.params.gamm[0] = 1.0;
m_processor->imgdata.params.gamm[1] = 1.0;
} else if (Strutil::iequals(cs, "Adobe")) {
// Request Adobe color space with 2.2 gamma (no linear toe)
m_processor->imgdata.params.output_color = 2;
Expand All @@ -554,8 +560,13 @@ RawInput::open_raw(bool unpack, const std::string& name,
} else if (Strutil::iequals(cs, "ProPhoto")) {
// ProPhoto by convention has gamma 1.8
m_processor->imgdata.params.output_color = 4;
m_processor->imgdata.params.gamm[0] = 1.8;
m_processor->imgdata.params.gamm[0] = 1.0 / 1.8;
m_processor->imgdata.params.gamm[1] = 0.0;
} else if (Strutil::iequals(cs, "ProPhoto-linear")) {
// Linear version of PhotoPro
m_processor->imgdata.params.output_color = 4;
m_processor->imgdata.params.gamm[0] = 1.0;
m_processor->imgdata.params.gamm[1] = 1.0;
} else if (Strutil::iequals(cs, "XYZ")) {
// XYZ linear
m_processor->imgdata.params.output_color = 5;
Expand Down Expand Up @@ -594,12 +605,6 @@ RawInput::open_raw(bool unpack, const std::string& name,
cs, LIBRAW_VERSION_STR);
return false;
#endif
} else if (Strutil::iequals(cs, "sRGB-linear")
|| Strutil::iequals(cs, "linear") /* DEPRECATED */) {
// Request "sRGB" primaries, linear reponse
m_processor->imgdata.params.output_color = 1;
m_processor->imgdata.params.gamm[0] = 1.0;
m_processor->imgdata.params.gamm[1] = 1.0;
} else {
errorf("raw:ColorSpace set to unknown value \"%s\"", cs);
return false;
Expand Down

0 comments on commit fa26dab

Please sign in to comment.