How does libvips compute the pixels average for images with transparent backgrounds? #2010
Unanswered
rapidcoder7
asked this question in
Q&A
Replies: 1 comment
-
Hello @rapidcoder7, Mostly, libvips treats images as simply big arrays of numbers, so it's more like Numpy than PIL, for example. All To calculate the the average of the non-transparent pixels, I would find the number of 0 pixels in the alpha, then flatten the image, take the histogram, subtract the number of 0 alpha from the histogram 0 count, and find the average of the hist. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using the avg() method to get the average of the pixels in an RGBA png image.
Out of curiosity I tried to compute the average myself. I compute the average of only those pixels for which the alpha band has a non zero value. However, my average is different from the value computed by the avg() method.
However, when I try to compute the average for an image with no transparent background, the self-computed value and the value returned by the avg() method are identical.
Beta Was this translation helpful? Give feedback.
All reactions