Differentiable shapes approximate an image.

Improved differentiable shapes with the depth function via priority vector.

Table of content

Post

In the last post I reproduced the results from the differential shapes articles but omitted the depth function. After looking into it I realized it could be done much easier than in the original article without the double argsort().argsort() trick, with just a weight vector.

notebook

Per pixel you calculate the weighted average:

color[x][y] = sum(i=(0, N), shape_color[i] * exp(-shape_w[i]) * shape_f[i][x][y]) / sum(i=(0, N), exp(-shape_w[i]) * shape_f[i][x][y])

Where shape_f is the splat function of the ith shape and shape_w is the weight. The weight should go through the exponent to enable the smoothmin kind of effect where you add stuff a * exp(w_a) + b * exp(w_b) and exponent just moves something linearly in digit space. Like if you add numbers in binary, exponentiation is right shift so it moves the bits of one term across the bits of the other term. This has the effect of making the sum depend more on one of the numbers. After the two numbers have been added, the result is normalized to ensure that the smaller number has a lesser impact on the final result.. 0b0001’0000 + 0b0000’0001 = 0b0001’0001, and then normalization makes sure the bits of the smaller term are moved right past the significance.

Also removed the negative color thing, with the weight vector it can learn to put a dark spot on top, which looks much cooler.

I like the sketchy look but not quite satisfied with the overall quality and will think about improving something else.

png

png

png

png

png

Links

[1]geometric-art-with-pytorch

[2]geometric-art-with-pytorch/youtube

[3]https://www.berkayantmen.com/rank.html

[4]https://arxiv.org/pdf/2006.16038.pdf