Populate geometry with information of image sampler?

Hi
i am trying to populate a square surface with points (normally the points are spread out evenly. I would like to have parts of the surface populated more and some less)
and getting this information from the image sampler
if i input a black and white image and i would like to have a linear distribution of points:
→ the math i got. Seems to make sence to me but maybe I am wrong

so: if all the brighnesses together have to add up to 100% of the points
→ x+1x+2x+3x+4x+5x+6x+7x+8x+9x+10x=100% of the points
→ 55x=100% of the points
→ x=1.1818181818% of the points

that means the parts that have 10% white and 90% black get 1,18181818% of the points
and the parts that have 20% white and 80% black get 3,636363636% of the points
and so on

is this assumption wrong?

if it is correct how do i translate this to grasshopper?
and if it is wrong can someone point me in the right direction?

thanks

Edit:
just realized. that only works if there are the same amout (areawise) of each grey (10% or 20%), because if for example only one very small part of the image is the 10% grey and it gets 1.8181818181% of the points it doesnt make sence. so there would also have to be an andition mathematical equasion to have this in it too

Edit 2:
so i just tried a part of it. probably not the most elegant way ^^ very slow. but works for low resolution for now.


so i took an image and layed a grid of points over the image. i then seperated the points according to the value of Black and white. With 10% steps. I also added a calculation for the percentage of image. so as we can see the 0-10% black makes up 38% of the image. i now have to somehow populate new points with the calculation on top and also add the % of each layer of black. hmm will update here ^^
maybe somebody finds it interesting :rofl:
Or has suggestions for improvment