<p>Below is how to change the colour of a shape in after effects based on the background colour at a given position:</p>
<p>Put a null on the position you wish to sample.</p>
<p>Put this expression in the fill colour of the object you want to change:</p>
<pre><code>target = thisComp.layer(&quot;BGLAYER&quot;);
colorpicker = thisComp.layer(&quot;sample 1 null&quot;);
target.sampleImage(target.fromWorld(colorpicker.position), [0.5,0.5], true, time)
</code></pre>
<p>BGLAYER
is the name of your background layer (eg your video)</p>
<p>sample 1 null
Is the null which is colour picking</p>
<p>You will also need a conditional statement in the expression to switch its opacity on or off - I'm not sure how to do that, but will add it to this answer if I work it out.</p>

CC BY-SA 4.0
2021-10-09T06:11:47.933Z
2021-10-09T06:11:47.933Z
tomh
<p>I'm trying to black out/censor segments of a screen-recording. I basically need something to check the color of a pixel on the video, and if the color does not match, it somehow censors the section of the video.</p>
<p>Example:
The source video needs to have at position 100;150 the color #f3f3f3. If this condition is true, just display the clip normally, if it's some other color, change the opacity to 0 or apply a blur.</p>
<p>(preferably in AfterEffects or PremierePro)</p>

<after-effects><premiere>
Change Opacity of Layer based on pixel value of another layer in PremierePro/AfterEffects
Mark Fooster
# Change Opacity of Layer based on pixel value of another layer in PremierePro/AfterEffects

(Asked by: username_0 on 2021-10-08)

I'm trying to black out/censor segments of a screen-recording. I basically need something to check the color of a pixel on the video, and if the color does not match, it somehow censors the section of the video.

Example:
The source video needs to have at position 100;150 the color #f3f3f3. If this condition is true, just display the clip normally, if it's some other color, change the opacity to 0 or apply a blur.

(preferably in AfterEffects or PremierePro)

**Tags:** after-effects, premiere


---

## 1 answers

### Answer by username_1 on 2021-10-09. Score: 0 | Accepted answer

Below is how to change the colour of a shape in after effects based on the background colour at a given position:
Put a null on the position you wish to sample.
Put this expression in the fill colour of the object you want to change:
target = thisComp.layer("BGLAYER");
colorpicker = thisComp.layer("sample 1 null");
target.sampleImage(target.fromWorld(colorpicker.position), [0.5,0.5], true, time)

BGLAYER
is the name of your background layer (eg your video)
sample 1 null
Is the null which is colour picking
You will also need a conditional statement in the expression to switch its opacity on or off - I'm not sure how to do that, but will add it to this answer if I work it out.


---

