ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Automatically track and adjust exposure values based on other source? Expression maybe?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Roger AlexanderAutomatically track and adjust exposure values based on other source? Expression maybe?
by on Nov 23, 2015 at 11:21:35 pm

I have a scene I shot with the subject sitting in a car by the window. Outside the window is a green screen that i will replace with a rainy city backdrop. In the scene I used a practical flickering light on the subject to imitate lightning.

My goal here is to match my city backdrop footage exposure to flash and darken at the same time as my foreground footage of the subject in the car with the lightning flashes so it looks like its lighting up everything in the scene and not just the subject.

My guess is that I could do this with an expression to match the exposure value of the city footage with the exposure value of a point in my foreground footage? Does anyone have something like this?

Or is there any easier way to do this without an expression? I have never used expressions in AE before so looking for some guidance.

Thanks

Roger


Return to posts index

Dave LaRondeRe: Automatically track and adjust exposure values based on other source? Expression maybe?
by on Nov 23, 2015 at 11:30:11 pm

I don't think you need to even bother with it. I think you're making needless work for yourself that in the end won't pay off for you.

How would you be able to tell which light in the background is passing and shining on the subject? The one you see pass right behind the subject? Nope, it's at the wrong angle. How about the streetlight overhead? Yes, but that's not even in the shot.

Tell you what -- put the shot together without the fancy expression for lightening and darkening and see what you think.

Dave LaRonde
Promotion Producer
KGAN (CBS) & KFXA (Fox) Cedar Rapids, IA


Return to posts index

Roger AlexanderRe: Automatically track and adjust exposure values based on other source? Expression maybe?
by on Nov 26, 2015 at 12:26:55 am

That didn't answer my question at all. It kind of feels like a troll reply. The city background will be far away and there will be no practical lights affecting the subject in the foreground.

My goal is that the background needs to light up when the foreground lights up. Is there an automated way to do this that anyone knows of?


Return to posts index


Kalle KannistoRe: Automatically track and adjust exposure values based on other source? Expression maybe?
by on Nov 26, 2015 at 1:56:40 pm
Last Edited By Kalle Kannisto on Nov 27, 2015 at 7:45:13 pm

(Dave probably read "lighting" instead of "lightning," that's what I did the first time. With lighting it wouldn't really matter.)

Ok, so you want to sample the foreground layer to see when the lightning strikes and apply it to the background as a color adjustment.

The basic method would be as follows.

1) Add a point control to the foreground layer. This is used to pick the point where you want to sample.

2) Add Brightness Contrast Effect to the background layer and use this expression for the Brightness value:

targetLayer = thisComp.layer(thisLayer.index-1);
samplePoint = targetLayer.effect("Point Control")("Point");
sampleRadius = [10,10];
sampledColor_8bpc = 255 * targetLayer.sampleImage(samplePoint, sampleRadius);
R = Math.round(sampledColor_8bpc[0]);
G = Math.round(sampledColor_8bpc[1]);
B = Math.round(sampledColor_8bpc[2]);
V = (R+G+B)/3;
V


That code will take a 20 by 20 pixel square area around the point set by a point control on the layer above (index-1), average the RGB value to a single value and apply it to the Brightness of the layer below. ANY shift in top layer's brightness will affect the brightness of the bottom layer. Thus, for practical purposes, you'd want to give "V" a threshold level, that occurs only during the actual flashes, above which it would affect brightness. And you could sample a smaller or larger area as needed. And if there are more layers in between you foreground and background layers, you'd have to change the layer selection value (index-[number of layers here]).


Return to posts index

Roger AlexanderRe: Automatically track and adjust exposure values based on other source? Expression maybe?
by on Nov 27, 2015 at 7:29:40 pm

This is exactly what I was looking for! Thanks Kalle I will try this out and let you know how it goes!


Return to posts index

Roger AlexanderRe: Automatically track and adjust exposure values based on other source? Expression maybe?
by on Nov 30, 2015 at 11:55:41 pm

Hello Kalle,

This works pretty well but I have a few questions. I have tried to research this myself, but alot of it is confusing to me. I'm not really a coder so it's like a different language and many times more complicated than what I'm looking for.

1. How do I set a minimum value for the brightness effect in the expression. For instance, my point control might set the brightness at 10 via the expression, but I want to set it so the brightness can never be below 20. So instead of 10 it stops at 20. Vice versa for max?

2. How do I set a threshold for the brightness, for instance, the values coming from the point control needs to be over "ABC" before raising the brightness.

3. How do I effect the ratios/increments for increasing the brightness. For instance a value of 1000 from the point control might result in raising the brightness value to 100. How do I modify this to where a point control value of 1000 translates to a value of 50 in brightness?

Thanks in advance!


Return to posts index


Kalle KannistoRe: Automatically track and adjust exposure values based on other source? Expression maybe?
by on Dec 1, 2015 at 7:46:06 am
Last Edited By Kalle Kannisto on Dec 1, 2015 at 8:08:08 am

Hi Roger,

"V" (in this code) is the brightness value that you need to do the math with.

1A. Minimum value: V = Math.max(20,V); (Using Max for minimum value may seem counter-intuitive at first, but you want the higher value of these two)

1B. Maximum value: V = Math.min(100,V); (If you want to set the maximum value to 100)

2. Threshold. This conflicts with the Minimum value code in 1A but basically:if (V<20) {V = 0};
To fix the conflict, you can combine minimum and threshold into one expression: if (V<20) {V = 0} else {V = Math.max(20,V)};

3. Ratio. Linear is a nice way to do this, for example: V = linear(V,20,100,20,50);
This will remap your input values (20-100) to a new range, in this case 20-50. The new range can be any two numbers.

So, it should work by adding this to the end of the existing code (I didn't test it):

if (V<20) {V = 0} else {V = Math.max(20,V)};
V = Math.min(100,V);
V = linear(V,20,100,20,50);

(You can drop the "V=" on the last line, as the result is used for the brightness value directly.)

Actually, that linear expression already takes care of your minimum and maximum input values. In other words, the whole thing boils down to adding this to the existing code (replacing the last line "V"):

if (V < 20) 0 else linear(V,20,100,20,50);


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]