evil-mad / stipplegen

Software that can create stipple drawings and “TSP art,” from image files
GNU Lesser General Public License v2.1
430 stars 52 forks source link

Question about the weighting method for recalculating centers #12

Open i-make-robots opened 6 years ago

i-make-robots commented 6 years ago

https://github.com/evil-mad/stipplegen/blob/master/StippleGen/StippleGen.pde#L838

What is going on with the scale factor and the maxSize here? The sample rate across a cell greatly affects the change to the voronoi... but I don't get why, it's not intuitive. None of the papers I've found discuss the tweaking you're doing here. Please break it down for me coz I'm lost and I'd really like to improve my weighting results.

I get that the rate is higher for smaller cells, and I have played with different rates. Bad scaling makes points jump around like crazy or settle into a nearly even grid. The sweet spot is hard to find!

oskay commented 6 years ago

We're essentially drawing a raster grid across the individual voronoi cell, and using that grid to compute the weighted centroid. (Why raster? Because we're comparing it to the original rastered image.) To keep accuracy and computation times reasonable, we scale each cell up (or down) to be about 50-100 pixels across, before creating the grid.

i-make-robots commented 6 years ago

In my code i used an consistent step size (1) regardless of cell shape. produced a very even grid of cells. Unsatisfied, I tried stepSize = maxSize/cellBuffer, but quality varies with number of cells (or relative cell size?). I tried the while loops as you have them and one number kept going to -infinity, never ending loop.

oskay commented 6 years ago

Um, there might be a bug in your code then?