A bit of basic g’mic script syntax question I guess.
But I try to count pixels matching a certain condition.
So I first set a variable to 0, and then with
eval wanted to run an expression that increments that variable.
But the variable cannot be accessed ‘live’ it seems. It’s substituted before the
eval commands run, right? So as far as
eval sees, it’s a constant value, not a variable that can be increments.
How can I do this efficiently?
Otherwise, I’m thinking of something like a
for (x=0;x<w;x++) loop inside a
for (y=0;y<w;y++), and no
eval at all, which doesn’t seem the best approach, or is it?
What I’m trying to do (because maybe there is another way), is to get the average (or the median maybe) value of pixels, but from a masked image. (So I have a single grey channel, and I have a mask with 0 or 255 values, and I only want the average of pixels where the mask is 255).