-
Incredibly slow looping sampleimage expression
Hello,
I’m trying to determine the height of a wave (a shape layer with just a path and a stroke) at various points along the x-axis. I’ve made (adapted) an expression to do a sampleImage starting at y=0, moving down the comp a pixel at a time, until it finds a pixel whose alpha is greater than 0.But it’s unbelievably slow to evaluate, sometimes just timing out. Any suggestions why this is happening? The “for” loop should only be looping a few hundred times to find the pixel. the wave does not change shape, so the expression only needs to evaluate once.
x=900;L=thisComp.layer("audioWave");
for (i = 0; i <= 1080; i++){
temp = L.sampleImage([x,i],[0.5,0.5],true,1);
if (temp[3] > 0) break;
}y=i;
[x,y]