• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

continuously change color of solid by averaging color of other section

New Here ,
Jun 22, 2019 Jun 22, 2019

Copy link to clipboard

Copied

Hi there,

I'm looking for a way to continuously change the color of a solid using the average color of another section.

So let's say I have a composition with an animation of a TV that plays something. The average color of what is shown on that TV should be used as color of a solid that is somewhere else in my composition. And because the average color of the TV continuously changes due to that it is playing someting, the color of the solid should change continuously as well.

I tried using Point Control effect on the TV layer and the following expression:

samplePoint = targetLayer.effect("Point Control")("Point");

sampleRadius = [100,100];

averageColor = 255 * targetLayer.sampleImage(samplePoint, sampleRadius);

but that only works once and not continuously. Also I can't get the solid color to be set to averageColor.

Any help is kindly appreciated!

cheers.

Leo

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 23, 2019 Jun 23, 2019
I have animated the position of the target layer. It appears that the point control moves with it. So it'll always pick the same color...

I am sure there is some code magic that can help with this. maybe https://forums.adobe.com/people/Dan%20Ebberts  can help with this.
but in the meantime try this:
create a color picker shape layer, put this in the color fill parameter in the shape:

target = thisComp.layer("target layer")

samplePoint = target.effect("Point Control")("Point");

sampleRadius = [100,100]

...

Votes

Translate

Translate
Advisor ,
Jun 22, 2019 Jun 22, 2019

Copy link to clipboard

Copied

Rather than trying to change the colour of the solid itself, apply a 'fill' effect to the solid and change the colour of that.

I think your expression above will work if you remove the 255* on the last line and apply it to the fill effect > colour property. Eg:

samplePoint = thisComp.layer("target layer").effect("Point Control")("Point");

sampleRadius = [100,100];

averageColor = thisComp.layer("target layer").sampleImage(samplePoint, sampleRadius);

Colours are measured on a normalised 0-1 scale in expressions so no need for the 255 multiplier.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2019 Jun 23, 2019

Copy link to clipboard

Copied

Great, that worked perfect to color the solid. I also found out why it wouldn't continuously do so.

the point control effect is on the target layer. I have animated the position of the target layer. It appears that the point control moves with it. So it'll always pick the same color...

I've now put the color picker & solid into a "master" comp. But that's not really great.

Is there an alternative way to do this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2019 Jun 23, 2019

Copy link to clipboard

Copied

I have animated the position of the target layer. It appears that the point control moves with it. So it'll always pick the same color...

I am sure there is some code magic that can help with this. maybe https://forums.adobe.com/people/Dan%20Ebberts  can help with this.
but in the meantime try this:
create a color picker shape layer, put this in the color fill parameter in the shape:

target = thisComp.layer("target layer")

samplePoint = target.effect("Point Control")("Point");

sampleRadius = [100,100];

averageColor = target.sampleImage(target.fromWorld(toWorld(anchorPoint)), sampleRadius);

(source: Use sampleImage() to create a color picker - aenhancers )


this will be your color picker. set it as a guide layer so it won't render.

in the solid layer put the effect Color Link and set the color picker layer as the source layer.

001.gif

here's the project file:

ColorPicker.aep - Google Drive

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 23, 2019 Jun 23, 2019

Copy link to clipboard

Copied

If you use Roei Tzoref's solution choosing Color Matcher instead of Color Link will give you the same thing but you will have the ability to work in a high bit depth (32) comp without using the HDR Compander. There is also an unnecessary line in the expression. SamplePoint is not used and can be eliminated. That means you can also eliminate the Point Control effect on the Target layer.

Personally, I would probably just add the Effect>Fill and tie it directly to the position of a Null. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2019 Jun 23, 2019

Copy link to clipboard

Copied

Thanks Rick, I have updated the project file. how do you mean fill and position of a null?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 30, 2019 Jun 30, 2019

Copy link to clipboard

Copied

Roei Tzoref, All you have  to do to use Fill and a null is to add this expression to Fill/Color

target = thisComp.layer("Your Footage");

point = thisComp.layer("Null 1").position;

radius = [100,100];

target.sampleImage(point, radius)

Then to make the sample point match the layer no matter how it is positioned, rotated or scaled Parent the Null to the "Your Footage" layer you are trying to sample. Don't have to play with layer space transformations. Holding down Shift when you parent will snap the null right to the anchor point of the layer you are sampling which makes it a lot easier to figure out where the sample is taken from. I think it is a little more straight forward than using a shape layer's color and sample image. Both approaches work.

If you do not want to parent the Null to the footage you want to sample you can add layer space transformations but it makes the expression a little more complex and does not gain you anything. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 01, 2019 Jul 01, 2019

Copy link to clipboard

Copied

thanks Rick, this works. the only thing is really that if you move the footage layer, the null will move to so you will have to readjust it later.
ColorPicker_v2.aep - Google Drive

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 05, 2019 Aug 05, 2019

Copy link to clipboard

Copied

LATEST

If you use Roei Tzoref's solution choosing Color Matcher instead of Color Link will give you the same thing but you will have the ability to work in a high bit depth (32) comp without using the HDR Compander.

Rick Gerard​ it just occurred to me that "color matcher" is not a native Ae effect but a 3rd party plugin part of the Key Correct suite by Red giant so that's worth mentioning. of course the method you suggested with fill effect works fine for the purpose as well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 29, 2019 Jun 29, 2019

Copy link to clipboard

Copied

Thanks Roei, Rick and Mike, you've all been a great help! And I've got it worked just how I want, thanks so much!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 23, 2019 Jun 23, 2019

Copy link to clipboard

Copied

Create a null object layer as use that as your sample point.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines