if I have a color image (RGB), what formula is used to calculate the “mean” that is in the variable {ia}?
What formula is used to calculate the intensity (luminosity) from the values R, G, B?
How do I quick calculate the mean if I want to use my own formula to calculate the intensity?
The math variable ia is actually the mean of all values of your image, regardless it is a RGB, RGBA or a X-channels image. ia is always a scalar value.
There are several ways to get the average vector-value in G’MIC.
One solution is to use the average_vectors command that returns a list of values from one image :
sp colorful
avg=${-average_vectors.}
echo $avg
If you want to compute this average vector-value directly from a math formula (e.g. in an eval command), then you can do something as:
sp colorful
eval "
V = vector(#s);
fill(V,k,avg(crop(#-1,0,0,0,k,w,h,d,1)));
print(V);
"