Author Topic: Average color  (Read 172 times)

Hi!
Is there a function for getting the average color of an image? It's quite resource intensive to blur it an insane amount.
Furthermore, can I get the average color within a mask?
Thanks
"Better than some, no worse than others."

To get the average color set the output size of your image to 1 pixel.

That's god damn genius. I guess I should be getting in the habit of downscaling for blurs anyway. Thanks a lot!
"Better than some, no worse than others."

No problem. I also found a way to get average colors within a mask working by translating the method described on stackoverflow to SD:
https://stackoverflow.com/questions/46907736/how-to-find-out-the-average-color-rgb-of-masked-area-of-an-image
Kudos to fmw42!

Now for the result:

We can have the average color of the masked area and it's inversion.

Increasing and decreasing the mask shape size:


Additionally, with a switch one could blend the input image and the averaged results together, if desired.
Grayscale version would be no problem either.
 

I do get the same result as you with this setup, so it's been super helpful. Both the mask and inverse mask behave as expected.



However, when I try to sample areas of an image, it seems to fall flat. Here I am generating masks for six different luminance values in the image. You'd expect the average color of each sample to get progressively lighter, but they don't:



And to confirm with a bit of a resource intensive solution, here is the same setup with another masking method:



Can you tell what's going on here? To me it seems like the mask isn't registering, and it's averaging the whole image.
"Better than some, no worse than others."

I whipped up a node and it seems to work fine here. Can you check with my node?
https://mega.nz/#!IVxVyAKC!hCim8DRCk7V7S7pFXZvkRfVt7s5cuXQHyLFyXjUDpYw

Last Edit: March 17, 2019, 03:51:44 pm

you can also use the transform nodes mipmap settings. same result really, so unless you absolutely do not want to deal with node sizes after the 1x1 there is not really any reason to use that approach over the 1x1 px node

The finished node is now on substance share: https://share.allegorithmic.com/libraries/5258