Re: [Gimp-developer] Masks not very effective in 2.9 scheme script



On Tue, 11 Jul 2017 00:38:17 +0100
Ken Moffat <zarniwhoop ntlworld com> wrote:

Hi,

TL;DR - using masks in a 2.8 scheme script works as intended to
extract parts of an image, but after converting it for 2.9 it does
much less.

The most likely reason for the different results, is that in 2.9 masks
use the pixels' linearized intensity as the alpha value, while in 2.8
they use the gamma-corrected intensity.  The linearized intensity
values are generally lower than the gamma-corrected ones, so the
resulting mask values, after pasting a desaturated image into the mask,
are lower in 2.9 than they would be in 2.8, resulting in a subtler
effect.  Note that these sorts of interactions is something we're still
working on.

For now, you have several options:  You can cast the mask values from
gamma-corrected ones to linear ones.  While there's no "obvious" way to
do that, there are several hackish ways.  For example, you could use
"colors -> components -> extract component", select any of the RGB
components, and enable "linear output".  You can do that either before
or after pasting the desaturated image into the mask; either way, you
should make sure to use high precision ("image -> precision"),
preferably floating point, or else there'll be notable data loss in
the intermediary results, in either the dark or the bright areas.
Unfortunately, this operation is not currently available to scripts.
You can get a good approximation for it using the levels tool instead
("colors -> levels"), with a gamma of 2.2.

Alternatively, you can avoid masks and use other forms of layer
compositing, although this might be more cumbersome.  Instead of
attaching a mask to a layer, keep both the masked layer and the mask as
ordinary layers, and put them in their own layer group, with the "mask"
layer below the "masked" layer.  Use "colors -> color to alpha", with
black color, on the mask, to turn black into transparency.  Then, set
the upper layer's mode to "multiply", or, alternatively, to
"normal" (from the default group), while also setting its composite
mode to "source atop" (in the layer attributes dialog).  If you want to
keep the mask layer opaque, then instead of using "color to alpha", add
a black layer above it, set its layer mode to "color erase" (from the
default group), and set its blend space to "RGB (perceptual)" (in the
layer attributes dialog).

All of the above (except as noted) is doable through a script, although
I'll leave it to you to work out the details :)  The procedure browser
is your friend.

--
Ell


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]