Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Colour analysis

  • Colour analysis

    Posted by Gary Noden on July 4, 2014 at 1:57 pm

    Hi there,

    I am trying to work out if it’s possible to create a script that applies a series of effects to a layer based on a colour analysis of a pixel, e.g., if the pixel at this coordinate is red, apply these effects, if the colour is green apply these effects, and so on so I can put a splat of a colour in the corner of a SWF in flash and from it apply the correct effects for that animation layer.

    Is there a way of calling this information in a script, such as using the colour picker to evaluate what they are? I can do something similar to this in Maya, but my knowledge of Adobe’s extendscript is limited at present.

    Any help would be greatly appreciated.

    Thanks

    Kevin Camp replied 11 years, 10 months ago 3 Members · 2 Replies
  • 2 Replies
  • Brian Charles

    July 4, 2014 at 2:33 pm
  • Kevin Camp

    July 4, 2014 at 4:45 pm

    you may be able to do this with expressions.

    expressions can’t add effects, but they can modify properties. so you may be able to have various properties look at a color and set themselves accordingly.

    i’m not sure this will work for your situation, but say you can add the effects to an adjustment layer. you can have the opacity of the adjustment layer look at the color of a pixel on a layer and set it to 100 if the pixel is red and 0 if it is not, effectively turning the effects on or off based on the pixel’s color.

    to sample a pixel using expressions you’d use the sampleImage() function. a basic expression to get the color value of a pixel would be like this:

    sourceLayer = thisComp.layer("My Source Layer"); // layer you want to sample
    p = [0,0]; // position of the pixel you want to sample
    r = [.5,.5]; // radius of the sample point
    sourceLayer.sampleImage(p,r)

    the expression will return a RGBA array in decimal form, so red would be [1,0,0,1].

    an advantage of expressions would be you don’t need to run it after a change, it will update as a change occurs. a disadvantage is that it will evaluate at every frame in the animation, so rendering will take longer – how much longer depends on how heavy the expressions are.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

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