navigate.tools.sdf.volume_from_sdf
- navigate.tools.sdf.volume_from_sdf(sdf, N, pixel_size=1, subsample_z=1)
Generate an (N, N, N) image from sdf.
- Parameters:
sdf (function) – A function that accepts (3, NxNxN) points as input and returns the Euclidean distance from each point to the object defined by the SDF.
N (int) – Length of volume axis.
pixel_size (float) – Rescale the image. Scaling must match object.
subsample_z (int) – Return only the values every subsample slices.
- Returns:
(N, N, N) image of SDF evaluated for each pixel.
- Return type:
npt.ArrayLike
Examples
>>> volume_from_sdf(lambda p: box(p, (15,15,30,)), 128)
Generates a (128, 128, 128) image of a box sdf. The sdf is <= 0 within 128//2-30 to 128//2+29 in z, 128//2-15 to 128//2+14 in x and y.