Adobe Creative Cloud

Digital Video & Audio

color sampler using sampleImage expression method

A little while ago, someone asked on a forum how they could get a readout of color values for one or more points that would update as you tweaked color correction settings.

I whipped together an expression using the sampleImage method.

The idea is simple: Have a text layer with its Source Text property tied to the output from sampleImage, with the input to sampleImage being a point control that you can drag someplace and then just leave it while you fiddle with your colors.

I’m not saying that this is the most elegant solution, but here is what I came up with.

On the layer that you want to measure, add a Point Control effect (one of the Expression Control effects). You can place the Point Control effect’s crosshair (effect control point) wherever you want.

Create a new text layer above the layer that you want to measure, and add this expression to the Source Text property:

targetLayer = thisComp.layer(thisLayer.index+1);
samplePoint = targetLayer.effect("Point Control")("Point");
sampleRadius = [1,1];
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]);
A = Math.round(sampledColor_8bpc[3]);
outputString = " R: " +R+ "r G: " +G+ "r B: " +B+ "r A: " +A

This will create a text layer that reports 8-bpc RGBA values for the point under the crosshair for the Point Control effect.

If you’re using an adjustment layer for your color correction, the adjustment layer is the layer that you’ll want to measure.

You can obviously get a lot fancier with this, but this should be enough to get you started.

After Effects, Region of Interest