Measure average brightness of texture

Hey there,

i am trying to find out how “filled” a texture can be besides real black black, so I thought to measure the average brightness of the image but i couldnt find anything that can give me back a single value on how bright the picture is.
Using the pipet seems to be no real option because of the heavy cpu usage when sampling all 1920x1080 points with it.
Is there maybe another solution to the problem that I am missing, besides writing it in c#??

You are not going to have that in c# in real-time, but you can have it in compute, what is the value you are looking for brightest and darkest pixel, or average of all the pixels (sum of pixels / amount of pixels)?

the ideal case would be to have a comparision between the “used pixels” (the ones that are above 0 lightness) and the “unused pixels” so that I can measure how much of the space of the texture is used.
Do you know any tutorial that I can use to get an idea what I have to do?
I am a complete newby in writing compute shaders.

This might help:
https://discourse.vvvv.org/t/creating-a-histogram-in-a-shader/

This not a beginner topic, there is two ways of dealing with this, one is an interlocked add or interlocked min max… I’ll check tomorrow I have something ready somewhere…

I think I use that to calculate overall luma in texture coming from some camera to detect finish if the mask is filled with white then it’s finish time… I guess you are looking for something similar?

Ok, so seems with interlocked add, it’s not going to work, since it works on int’s and uint’s only. Guess this meant to work with something you have to increment an amount off…

Instead there is a second tech, when you draw all the pixels of your texture exactly at (0,0,0), using add as blend mode, so you have one pixel containing all the brightness of the texture…

SumPixelsAnt.zip (10.9 KB)

2 Likes

Ah that sounds like a way faster method to measure the average brightness by adding them all together!
I’ll check the sumpixelsAnt tomorrow :D
Thanks so much for the help antokhio!!

I finally found the time to check the SumPixels node and it is super awesome!!
The VSCode is beyond my understanding!^^ I hopefully manage some day to write that on my own!

Do you have some tutorials on how to write compute shaders?

Thanks so much for the help :)

I think was supposed to be recorded during node 2017 with Mr.Vux but i haven’t seen them online…
If you have a topic of interest i can do a video, problem is that compute field has many applications and all of them have some specific stuff, so to cover everything is to cover nothing basically…

I guess i’ll do some beginner at list, with setup and all the stuff related for the general approach…

1 Like

That would be superawesome!
I am currently looking into JavaScript to start and learn how to code.
Later I want to learn to write my own shaders for vvvv.
We’ll see how that will turn out^^

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.