Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Grab average color of layer to determine the color for another effect?

  • Grab average color of layer to determine the color for another effect?

    Posted by Nils Hoover on May 22, 2012 at 4:08 am

    Basically I want to create some false lighting for a keyed layer I am working on. I have a window in a house keyed and have multiple clips playing behind the window, but I want the highlights on the edge of the window to change color with the footage outside of the window.

    I guess I am imagining I would somehow average the colors from the footage on the bottom layer, then add an effect (For example using something as simple as “photo filter” or “tint”) which is grabbing that color information and using it to color the top layer.

    If there is no easy way of averaging the colors through expressions, I know I could always just blur it on a hidden layer or something.

    I am a beginner with expressions, but I am sure you could do this with one right?

    What might be the best way to do something like this?

    Nils Hoover replied 14 years, 3 months ago 3 Members · 5 Replies
  • 5 Replies
  • Roland R. kahlenberg

    May 22, 2012 at 4:47 am

    The sampleImage Expression method should do the trick for you. More info here in the doc here->
    https://help.adobe.com/en_US/AfterEffects/9.0/WS3878526689cb91655866c1103906c6dea-7a00a.html.

    There are links to examples which will guide you further.

    Instead of using Fill or Tint, see if Tritone will get you a more believable look. Let us know if you have specific Qs.

    Good Luck
    RoRK

    Intensive AE & Mocha Training in Singapore and Malaysia
    Adobe ACE/ACI (version 7) & Imagineer Systems Inc Approved Mocha Trainer

  • Kevin Camp

    May 22, 2012 at 2:33 pm

    a really easy way is to just use the mosaic effect with the blocks set to 1. that should give you a pretty good ‘average’ color for a frame.

    then you could try using that layer with blending modes to blend it with the layers below.

    but a fairly simple sampleImage() expression to drive any color chip setting in an effect would be something like this:

    target = thisComp.layer("MyLayer"); // this would be the layer that you want to sample the color from
    h = target.height / 2;
    w = target.width / 2;
    target.sampleImage(anchorPoint, radius = [w, h], postEffect = true, t = time);

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Kevin Camp

    May 22, 2012 at 2:36 pm

    actually, i’ll make one slight change to the expression.

    target = thisComp.layer("Royal Blue Solid 2"); // this would be the layer that you want to sample the color from
    h = target.height / 2;
    w = target.width / 2;
    target.sampleImage(target.anchorPoint, radius = [w, h], postEffect = true, t = time);

    the change was to the last line, rather than using the anchorPoint of the layer with the effect for the ‘sample point’, it’s probably better to use the target layer’s anchor point.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Nils Hoover

    May 22, 2012 at 3:02 pm

    Thank you! that has really gotten me on the right track, and does exactly what I needed.

  • Nils Hoover

    May 22, 2012 at 3:07 pm

    Thank you, tricolor definitely is a better option, and works quite nicely with out any hassle.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy