datashader icon indicating copy to clipboard operation
datashader copied to clipboard

Smoother spreading step size

Open jbednar opened this issue 4 years ago • 0 comments

#1001 introduces fixes to dynspread that make it work as well as it can given the assumptions of:

  1. binary spreading masks (each pixel on or off), and
  2. symmetrical masks, which require odd sizes 1x1 (no spreading), 3x3, 5x5, 7x7, etc.

Still, the big size jumps between 1x1 and 3x3 and between 3x3 and 5x5 cause sharp discontinuities in the appearance of spreading, going from no spreading to quite a bit of spreading in one step:

image image

The dynspread neighborhood metric from #1001 is perfectly matched to these steps, as it also checks only at 1x1, 3x3, etc. for neighbors. If we want to make the progression of spreading sizes smooth, I think we can do so with minimal changes to the current approach if we (a) use floating-point spreading arrays with antialiased shapes, and (b) linearly interpolate sizes between px-1 and px using the neighborhood metric values for those px values, weighting between e.g. 3x3 and 5x5 according to how close the metric is to the threshold. E.g. if the threshold is 0.5 and the metric is 0.1 at 3x3 and 0.6 at 5x5, the floating-point neighborhood size would be something like 4.6x4.6 (i.e., 3+2*((0.5-0.1)/(0.6-0.1))).

This approach doesn't seem terribly complicated and is something we can do if we are irritated by the large spreading jumps in practice.

jbednar avatar May 27 '21 01:05 jbednar