- Community Superstar
- Has been a member for 2-3 years
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Author was Featured
- Author had a File in an Envato Bundle
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
So Felt, I have this prob…. sorry, I mean, guys I have this problem with expression.
Here is what I need. I need AE to read out certain pixels, for example 20×20 but only alpha value. (For example, precomposed vector logo). Expression would be on a certain layer’s opacity and basically it would be something like this:
if(most of the pixel’s readout from 20×20 pixel area alpha==1){ then this layer’s opacity is 100} else 0;
I was trying with sampleImage and from Dan Ebberts website, I found an expression which would be most similar, but I just cannot make it work the way I want:
target = thisComp.layer(“clouds”);
alpha = target.sampleImage(effect(“Lens Flare”)(“Flare Center”),[3.5, 3.5])[3];
linear(alpha, 0, 0.36, 80, 10)
Thanks in advance.
target = thisComp.layer("target_comp"); //comp from where you want to get alpha
samplePos = thisComp.layer("Eyedropper").transform.position;
//"Eyedropper" - null object, pick up location from wich to sample
r = 20; //radius
alpha = target.sampleImage(samplePos, [r,r], true, time);
if(alpha[3] >= 0.5) x = 100
else x = 0;
//if alpha in that location is less then 50% x = 0
[x]
That is all 
- Community Superstar
- Has been a member for 2-3 years
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Author was Featured
- Author had a File in an Envato Bundle
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
DOGmotion said
I’m not Felt, but…target = thisComp.layer("target_comp"); //comp from where you want to get alpha samplePos = thisComp.layer("Eyedropper").transform.position; //"Eyedropper" - null object, pick up location from wich to sample r = 20; //radius alpha = target.sampleImage(samplePos, [r,r], true, time); if(alpha[3] >= 0.5) x = 100 else x = 0; //if alpha in that location is less then 50% x = 0 [x]That is all![]()
wow, it works!!!! Thank you so muuuuch! 
No problem, man 
- Community Moderator
- Sold between 50 000 and 100 000 dollars
- Author was Featured
- Item was Featured
- Author had a File in an Envato Bundle
- Beta Tester
- Has been a member for 4-5 years
- United Kingdom
Yeah…. what DOGmotion said. 
Hey Felts, is it allowed to perhaps create a forum section on expressions we use to give to other authors? Or is that a noon? For instance, to help other folks, post expressions on controls I have made, or expressions used to help others?
PHANTAZMA said
Hey Felts, is it allowed to perhaps create a forum section on expressions we use to give to other authors? Or is that a noon? For instance, to help other folks, post expressions on controls I have made, or expressions used to help others?
I mean “No No”. Thanks spell check.
PHANTAZMA saidIt sounds like an idea for a new project…
Hey Felts, is it allowed to perhaps create a forum section on expressions we use to give to other authors? Or is that a noon? For instance, to help other folks, post expressions on controls I have made, or expressions used to help others?

Just thinking usually if I am trying to figure out how to do a specific expression of course I search the web and usually find what I need. But perhaps create a resource of expressions that may help each other and save have to scour the internet.
PHANTAZMA said
Hey Felts, is it allowed to perhaps create a forum section on expressions we use to give to other authors? Or is that a noon? For instance, to help other folks, post expressions on controls I have made, or expressions used to help others?
+1
