Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions extracting rgb values from color control

  • extracting rgb values from color control

    Posted by Kevin Camp on July 26, 2007 at 3:55 pm

    i’m trying to get the rgb values from color that would be selected with an eye dropper (as in the color control expression control).

    currently, when i try to get the value it is a single number, a decimal ranging from 0-1 (atleast in an 8bpc project). i’ve tried hslToRgb and rgbToHsl on that value, and get an array, but the decimal values returned don’t seem to match the rgb values i can see in the color picker.

    is there a way to extract the rgb values from a color selected by a color selection effect similar to color control?

    Kevin Camp
    Designer – KCPQ, KMYQ & KRCW

    Marcelo Mazzariol replied 18 years, 3 months ago 5 Members · 8 Replies
  • 8 Replies
  • Colin Braley

    July 26, 2007 at 4:05 pm

    When you refernce a color control, you should get a value back that is an array of length 4, in the format [r, g, b, a]. Each item in this array ranges from 0 to 1. If you wanted to see the values like you would in the color picker, multiply every element in the array by 255. Try something like this:

    colors = effect(“Color Control”)(“Color”);
    colors * 255

    However, I don’t see why you would need to do this in most cases, because if you are using this value to drive a color control within another effect, it expects its values to range from 0-1, not from 0-255.
    ~Colin

  • Kevin Camp

    July 26, 2007 at 4:23 pm

    thanks colin… for some reason when i was trying to get a value from my color, i didn’t get an array of values, like i was expecting. i just got a single decimal value… now it works, user error, i suppose.

    thanks again.

    Kevin Camp
    Designer – KCPQ, KMYQ & KRCW

  • Darby Edelen

    July 26, 2007 at 5:11 pm

    [Colin Braley] “However, I don’t see why you would need to do this in most cases, because if you are using this value to drive a color control within another effect, it expects its values to range from 0-1, not from 0-255.”

    Yes, generally you will be dealing with scenarios in which you want the user to enter values in the range 0-255 and end up with a value in the 0-1 range (which is how AE handles color internally).

    Also, you can find the number of levels for each channel using:

    Math.pow(2, colorDepth);

    This is really only useful for 8bpc or 16bpc projects, in float the numbers would be huge and are represented in the 0-1 range (with numbers greater than 1 being superwhite) in effects such as levels anyway.

    May I ask what you are trying to accomplish with your expression?

    Darby Edelen
    DVD Menu Artist
    Left Coast Digital
    Aptos, CA

  • Kevin Camp

    July 26, 2007 at 6:30 pm

    i was looking into linking color samples to a levels adjustment to create a way to use those samples to generate a white point, black point and midtone values in the the levels adjustment, much the way that photoshop levels can use the eye dropper to set those values within the its levels adjustment tool.

    my confusion came when i wanted to see what the value of a color sample within the color control was by linking the sample to the source text of a text layer and got a single decimal value, and i was expecting an rgb array. i could n’t figure out what the number represente, so i thought i’d ask… turns out i just made some mistake when i linked it to the source text. once colin told me it should work more like i had expected, i tried again and it gave me what i was looking for…. ooops.

    Kevin Camp
    Designer – KCPQ, KMYQ & KRCW

  • Darby Edelen

    July 26, 2007 at 6:46 pm

    The decimal values of colors can often be a little confusing at first, but it is more versatile (and correct) than thinking in terms of 0-255.

    Just remember that 0 is black and 1 is white and everything should fall into place (;

    When AE makes blending calculations it must use values in the range of 0 to 1 (for non-HDR) to give the results you’re accustomed to. For example, a solid layer with a color value of [0.5, 0.5, 0.5, 1] under an identical solid layer set to ‘Multiply’ will result in a total color value of [0.25, 0.25, 0.25, 1].

    Where as if you set the top layer to ‘Add’ it will result in a total color value of [1, 1, 1, 1].

    If the color values ranged up to 255 these simple mathematical blending functions would behave very differently!

    Darby Edelen
    DVD Menu Artist
    Left Coast Digital
    Aptos, CA

  • Filip Vandueren

    July 28, 2007 at 1:12 am

    Looks like you might be trying to re-invent the wheel.

    Stu Mascwitz has created an After Effects preset to download for us all, that does just what you described and more:

    https://prolost.blogspot.com/2006/10/rebel-cc.html

    Show him some love by buying his book “the DV rebel’s guide” 😎

  • Kevin Camp

    July 30, 2007 at 2:18 pm

    thanks, i’ll check it out… i just had some free time and like trying to figure out how to use expressions and expression controls. i’ve been somewhat annoyed for years about the differences between many of ps’s and ae’s common adjustment interfaces, and thought i would try to tackle this one.

    one thing i can’t seem modify is the sample size for ae’s eye dropper. in ps you can set a larger sample size than just one pixel (like 3×3), which is often useful. but, i’ll check out the presest, thanks.

    Kevin Camp
    Designer – KCPQ, KMYQ & KRCW

  • Marcelo Mazzariol

    February 5, 2008 at 1:30 pm

    I´ve just been tying something similar.

    Yes I´ve found Rebel CC and 3WayCB and they are very handy. For those how don´t know them yet, check the presets at https://prolost.blogspot.com

    Back to where I was: … well, I´m trying to control the preset by choosing color from an image, a selected area of the image, its average, … something like that…, instead of the color picker. Done that, it would be possible to return the information to the color control and set it.

    It won´t make any grate changes to how the presets work, but I believe it will save some clicks on the way.

    Thks.
    Marcelo

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