Hi Ivan,

If you think of each deep sample as a light absorber of a unit length
then each sample has an absorbance amount which can be derived from
the alpha. So 1 - alpha = transmission.  Absorbance = -ln(
transmission ).  ( from beer lambert ).

DeepRecolor rebalances the alpha values by considering the relative
absorbance of each sample rather than the relative alpha.

So:

orig alpha: 0.52
targe alphat: 0.9

orig absorbance: -ln( 1.0 - 0.52 ) = ~0.733
target absorbance: -ln( 1.0 - 0.9 ) = ~2.302

gain = target absorbance/orig absorbance = ~3.137

Samp1 :  alpha = 0.4
Samp2 :  alpha = 0.2

Samp1: absorbance = -ln( 1.0 - 0.4 ) = ~0.510
Samp2: absorbance = -ln( 1.0 - 0.2 ) = ~0.223

Samp1: target absorbance = ~ -0.510 * 3.137 = ~ -1.602
Samp2: target absorbance = ~ -0.223 * 3.137 = ~ -0.700

Samp1: target alpha = 1.0 - exp(-1.602) = ~0.798
Samp2: target alpha = 1.0 - exp(-0.700) = ~0.503

The last few calculations can be simplified as well.

If we consider,

target transmission =  exp( -gain * absorbance )

and,

absorbance = -ln( transmission )

then new target transmission is:

exp( gain * ln( transmission ) )

which is just,

pow( transmission, gain )


Also for reference, there's a couple of great papers on the exr site
by Florian and Peter Hillman which go into great detail on what deep
samples represent and how to manipulate them.

http://www.openexr.com/documentation.html  ( links are at the bottom
of the page )

Cheers,
Jon.

On Mon, Dec 16, 2013 at 8:33 PM, Ivan Busquets <ivanbusqu...@gmail.com> wrote:
> Thanks Steve,
>
> In this case, I'm talking opacity only.
>
> Color values seem to follow the same logic as non-retargeted recoloring.
> That is, divide by the input alpha, and multiply by each sample's alpha.
>
> It's the re-distributed alpha values that I can't find the secret sauce for
> :)
>
>
>
>
> On Mon, Dec 16, 2013 at 12:29 PM, Steve Booth <st...@boothsoft.com> wrote:
>>
>> Ivan,
>>
>>
>>
>> The luminance equation comes to mind:
>>
>>
>>
>>                 Y = 0.2126 R + 0.7152 G + 0.0722 B
>>
>>
>>
>> I'm wondering if the Recolor is trying to maintain essentially the same
>> luminance during the recolor operation.  Thus, for example, if you are
>> shifting to the blue, you might actually want a higher opacity?
>>
>>
>>
>> Just a guess...
>>
>>
>>
>> Steve
>>
>>
>>
>>
>>
>> From: nuke-dev-boun...@support.thefoundry.co.uk
>> [mailto:nuke-dev-boun...@support.thefoundry.co.uk] On Behalf Of Ivan
>> Busquets
>> Sent: Monday, December 16, 2013 12:18 PM
>> To: Nuke plug-in development discussion
>> Subject: [Nuke-dev] How is DeepRecolor distributing a target opacity
>> amongst samples?
>>
>>
>>
>> Hi,
>>
>> Not strictly a development question, but I figured there would be a better
>> chance of someone in this list knowing what's happening under the hood here.
>>
>> Long story short, I'm trying to implement a procedure to re-target opacity
>> of each sample in a deep pixel, akin to what's happening in a DeepRecolor
>> node when "target input alpha" is checked.
>>
>> I've got this to a point where it's working ok, but I think I might be
>> missing something, as my results differ from those you'd get in a
>> DeepRecolor.
>>
>> My re-targetting algorithm is based on the assumption that the relative
>> opacity between samples should be preserved, but DeepRecolor clearly uses a
>> different approach.
>>
>> Example:
>>
>> Say you have a deep pixel with 2 samples, and the following opacities:
>>
>> Samp1 :   0.4
>>
>> Samp2 :   0.2
>>
>> The accumulated opacity is 0.52  (Samp1 over Samp2). Note that Samp1
>> deliberately has an opacity of 2 times Samp2.
>>
>> Now, let's say we want to re-target those samples to an accumulated
>> opacity of 0.9.
>>
>> What I am doing is trying to calculate new opacities for Samp1 and Samp2
>> in such a way that Samp1 == 2*Samp2 and Samp1 over Samp2 == 0.9
>>
>> This gives me the following re-targeted values:
>>
>> Samp1 :   0.829284
>>
>> Samp2 :   0.414642
>>
>>
>>
>> I'm happy with those, but it bugs me that DeepRecolor throws different
>> results:
>>
>>
>>
>> Samp1 :   0.798617
>> Samp2 :   0.503434
>>
>> Which meets the Samp1 over Samp2 == 0.9 criteria, but does not preserve
>> the relative opacities of the original samples.
>>
>> It seems to me like DeepRecolor is applying some sort of non-linear
>> function to apply a different weight to each of the original samples, but I
>> haven't been able to figure out the logic of that weighting, or a reason why
>> it's done that way.
>>
>> Does anyone have any insight/ideas on what DeepRecolor might be doing
>> internally?
>>
>> Or a reason why you might want to distribute the target alpha in a
>> non-linear way?
>>
>>
>>
>> Thanks,
>>
>> Ivan
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Nuke-dev mailing list
>> Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>>
>
>
> _______________________________________________
> Nuke-dev mailing list
> Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev
>



-- 
Jon Wadelton, Nuke Product Manager.
The Foundry
5 Golden Square, London, W1F 9HT
Tel:  +44 20 7479 4350 • Web: www.thefoundry.co.uk

The Foundry Visionmongers Ltd • Registered in England and Wales No: 4642027
_______________________________________________
Nuke-dev mailing list
Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev

Reply via email to