Activity › Forums › Adobe After Effects Expressions › How to access pixel RGB values from a script? (not an expression)
-
How to access pixel RGB values from a script? (not an expression)
Posted by Paulo Jan on April 18, 2014 at 11:17 amHello:
This is a question about scripting, not strictly about expressions, but I thought it would fit better here than in other forums.
I am writing a script that needs to access the RGB pixel values of a given comp/layer. Reading through the scripting guide, I haven’t found any way to do it. Is there a way? What I need is to be able to specify a given X/Y coordinates and get back the RGB values of that pixel, as if it was Photoshop.
Thanks in advance.
Paulo Jan replied 12 years ago 3 Members · 6 Replies -
6 Replies
-
Dan Ebberts
April 18, 2014 at 1:24 pmUnfortunately, scripting doesn’t have that functionality directly. You can do it by having the script add a temporary expression though. Add the expression, harvest the result, remove the expression.
Dan
-
Paulo Jan
April 18, 2014 at 2:53 pm -
Paulo Jan
April 18, 2014 at 4:55 pmMore generally speaking, I’d like to know if it’s possible to use either expressions or scripts to manipulate a layer/comp at a bitmap level. That is:
-Set given pixels to a certain color, based on their brightness level (as in the image above).
-Take a snapshot of the current comp and perform calculations on it as a bitmap, and then save it as a JPG.
Thanks in advance.
-
Dan Ebberts
April 18, 2014 at 5:25 pmI don’t know of any practical way to do that with a script. Maybe with a plugin, but that’s a much steeper learning curve.
Dan
-
Darby Edelen
April 23, 2014 at 5:16 am[Paulo Jan] “-Set given pixels to a certain color, based on their brightness level (as in the image above).”
You could use one of the keyers (Color Range? Extract?) and Channel > Solid Composite to do that.
[Paulo Jan] “-Take a snapshot of the current comp and perform calculations on it as a bitmap, and then save it as a JPG.”
This part has me a little confused. If you want to perform calculations on the image inside of AE then I would expect that is most likely scriptable depending on what the goal is. What is the goal?
Darby Edelen
-
Paulo Jan
April 23, 2014 at 3:13 pmOkay, let me explain. I’m trying to port to After Effects this Bridge script:
https://davidmilligan.github.io/BridgeRamp/
Which deflickers an image sequence. The way it works is by computing an histogram of every selected image, then comparing the brightness level of a given percentile and adjusting the images’ exposures until they all match.
For it to work, I need to access AE’s composition as a bitmap, measuring the pixel’s RGB values to construct the histogram. That can be done using Dan’s method, though it’s a bit kludgy…
…but the script also provides a preview of which parts of the image are in a given percentile. You select a value, hit “Preview” and it shows you in red the corresponding parts of the image. The way the script does it is by creating a temp JPG file, which is why I was asking about that in my previous question.
Now that you mention using one of the keyers… I’ll have to think about it. But still, it’s quite a kludge (reading the AE scripting guide, it’s obvious that it’s not designed to do stuff like this *at all*), and there’s also the matter of performance…
Reply to this Discussion! Login or Sign Up
