Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects exspression pixel sampler

  • exspression pixel sampler

    Posted by Emma Nichols on May 17, 2011 at 5:25 pm

    Hi, I basicly I have a layer with 6 colour changing circles on it. I would like to be able sample the colour of each circle as it changes and then attach another effect to the rgb values?

    Exactly like the pixel sampler preset really. ( The preset will not work for me, I have tried everything to make it work but keeps appearing with bad argument, can’t find ect… ) So looking for a manual way of doing it?

    Emma Nichols replied 14 years, 12 months ago 4 Members · 5 Replies
  • 5 Replies
  • Walter Soyka

    May 17, 2011 at 5:52 pm

    [Emma Nichols] “I would like to be able sample the colour of each circle as it changes and then attach another effect to the rgb values? Exactly like the pixel sampler preset really. ( The preset will not work for me, I have tried everything to make it work but keeps appearing with bad argument, can’t find ect… ) So looking for a manual way of doing it?”

    You can do this in any expression with sampleImage() — just look at the expression in the Sampled Color Output value for an example of how to use it.

    That said, if the Sample Image Expression preset isn’t working for you, there’s something that you’re not quite doing right, and you’ll likely have the same problem with the expression.

    All you need to do is add the Sample Image Expression preset to a layer. Find the color property you’d like to drive with Sample Image, then Alt-Click its stopwatch icon and pickwhip the “Sampled Color Output” property of the Sample Image effect.

    If you’re running into problems, a screenshot might help.

    Walter Soyka
    Principal & Designer at Keen Live
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    RenderBreak Blog – What I’m thinking when my workstation’s thinking
    Creative Cow Forum Host: Live & Stage Events

  • Emma Nichols

    May 17, 2011 at 8:31 pm

    Thanks

    Sorry I didn’t mean the sample image preset I meant the CE pixel Sampler https://maltaannon.com/articles/after-effects/ce-pixelsampler/

    sorry I am really new to expressions, tried this in the shape color fill which is linked to a point control and the color does change as I move the point control around but the colors aren’t the same?

    targetLayer = thisComp.layer(“background”);
    samplePoint = targetLayer.effect(“Point Control”)(“Point”);
    sampleRadius = [0.5,0.5];
    sampledColor_8bpc = 255 * targetLayer.sampleImage(samplePoint, sampleRadius);

    Here is a screen shot … https://farm4.static.flickr.com/3265/5731500310_0371ebabf1_b.jpg

    I am trying to make the color of the square change as the point roles over different colors ?

    Thanks again …. really want to work this out have a deadline for uni 🙁

  • Brian Charles

    May 17, 2011 at 9:30 pm
  • Darby Edelen

    May 18, 2011 at 4:44 am

    [Emma Nichols] “targetLayer = thisComp.layer(“background”);
    samplePoint = targetLayer.effect(“Point Control”)(“Point”);
    sampleRadius = [0.5,0.5];
    sampledColor_8bpc = 255 * targetLayer.sampleImage(samplePoint, sampleRadius);”

    You definitely don’t want to multiply the result of sampleImage() by 255. Every color property is expecting inputs in the range of 0 (black) to 1 (white) regardless of what bit depth you’re working in.

    Multiplying the result by 255 will pretty assuredly result in white every time. For example, a returned value of [0.5, 0.5, 0.5, 1] (middle gray) from sampleImage() would be multiplied by 255 to become [128, 128, 128, 255] which is 128 times brighter than white!! This result is clipped to white (1) if you’re not working in 32bpc.

    Darby Edelen

  • Emma Nichols

    May 21, 2011 at 4:57 pm

    Thanks!! took away the 255 and works perfectly

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