Weighted Voronoi Stippling - study

3dxml below,

 

I decided to delete the initial post to avoid confusion, and am sorry for the people that kindly commented and thumbed it up 

My initial thought was to replicate what was explained in the video of the coding train youtube channel. because I found it interesting to know how to control and smooth a Voronoi mesh, for beauty but also it could arise as an industrial need to have point distribution between evenly and full random. It think it could be linked about close packing of circles which will be on another post.  I am not clear yet on it though. and as always, understand that my posts are not so deep search, rather shallow studies, sharing my ways and merits of visual scripting and apps on 3DX platform...beware of mistakes

https://www.youtube.com/watch?v=Bxdt6T_1qgc

 

Here is the logic

1 Import the picture and link a surface to it

  • basically, I made a rectangle where 1sqmm = 1 pixel. no scaling to keep it simple

forbidden question: Why a monkey?

2 Generating a random sampling of points on dark zones

my intention is to have a sampling of points which looks random while more concentrated on dark area!

If you place a point where darkness is more than "0.5", in this case you get aresult which looks good but then you completely remove bright area. it is like a desert zone, then you miss the "stippling effect". you need to stipple bright area as well, but not so much

The video of youtube explains how to place point if the pixel darkness is more than a randomly chosen probability. as the darkness value is closer to 0 and brightness to 1, the probability to get a point on dark pixel is higher than on bright one. But, you can still get point on completely bright pixel.

initial point sampling
points with a darkness above 0.5
points with a darkness above a random probability

logic

  1. sample the surface with points
  2. evaluate the brightness of its corresponding pixel
  3. generate random probability numbers, as many as the sampling number of points
  4. get the point if the rescaled darkness (1-rescaled brightness) is above its random number

3 Weighted Voronoi

the Voronoi you get with the above distribution of points is good. However, it is missing a certain regularity within randomness that makes it human and give the stippling effect. the purpose is to emphasize the contrast (bright/dark) while getting a more regular distribution of points!!! 

To do that, we relax the Voronoi following the same logic as Lloyd Algorithm, which is well explained in the video. At least, I could understand better than with below wikipedia link

 

 

 https://en.wikipedia.org/wiki/Lloyd%27s_algorithm

If we followed Lloyd relaxation, in the end, you get an even distribution! it blurs the image. So to get the intended result, I weighted the Voronoi cell's vertexes with underlying pixel darkness values. weighting with all the Voronoi cell points is impossible because of computing time. but just the cell vertex gave results I found OK.

the logic is loop below

  • create the Voronoi cells out of the point distribution
    • the points are the cell's barycenters, the centroids
  • calculate another barycenters of the cells by applying a darkness weight to the cell's vertices
  • move the centroids of the cell towards the weighted barycenter
  • use the moved centroids as input for next loop

it takes few tens of minutes 30mn 1h depending on my tests. in youtube video it looks instant. I wish relaxation could be faster. but we are on a geometrical modeler while in youtube they are only on pixels.

  • then create visualize the point with circles or sphere and link radius to the weigthed centroid average brigthness of the zone

here is some results

Voronoi 50 iterations with translation of 0.2 distance of the weighted centroid and the no-weight centroid
with central points (circles with radius related to darkness)
with central points (circles with radius related to darkness) - no voronoi

 

It worked well because dark zones of the Monkey are really dark, therefore getting initial points are OK

below with Nefertiti, I had to do 20000 initial points to get enough for the Voronoi. then, I just did 10 iteration for the relaxation otherwise, she looked like a mummy.