Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Pixel value reading to use with other parameters.

  • Pixel value reading to use with other parameters.

    Posted by Steve Clarke on June 30, 2023 at 12:50 pm

    Hi there,

    Is there a simple way to read the luminance value of a pixel or group of pixels to dynamically adjust a pick whipped value in another layer. I would like to adjust the exposure, highlights etc based on a flickering light from another layer.

    Thanks in advance for any help offered.

    Rick Gerard replied 3 years, 2 months ago 2 Members · 1 Reply
  • 1 Reply
  • Rick Gerard

    June 30, 2023 at 7:04 pm

    You can use ReferenceLayer.sampleImage(position, radius[10, 10]) to sample the RGBA values of a layer then use rgbToHsl[2] to convert the RGB value to a linear value. You can then set up a linear interpolation method to drive the values in Exposure within the range you want. For example, this expression added to exposure will take the position of the current layer and adjust the exposure value as the luminance of the layer changes under the current layer.

    ref = thisComp.layer(index + 1);

    v = ref.sampleImage(position, radius = [.5, .5], postEffect = true, t = time);

    t = rgbToHsl(v)[2];

    linear(t, .25, .75, -1, 2)

    You might want to replace position in the expression with the position of a null layer so you can easily drag the null over the flickering light. Color values range between zero and one, and exposure values are based on a f-stop (logarithmic scale) so you might have to fiddle with the values.

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