facebookresearch / DeepSDF

Learning Continuous Signed Distance Functions for Shape Representation
MIT License
1.38k stars 255 forks source link

Remove rounding errors in create_mesh #68

Open bguillard opened 3 years ago

bguillard commented 3 years ago

In the current code for sampling a grid of SDF values, there is a rounding error in the computation of the regularly spaced 3D coordinates of the grid. To exemplify my point, for N=256 (default), the (x,y,z)=(1,1,1) edge of the bounding box instead has coordinates

>>> samples[-1, :]
tensor([1.0078, 1.0078, 1.0000, 0.0000])

This error does not only affect coordinates on the cube's boundaries, but the whole volume. I propose to properly carry integer division, which now yields:

>>> samples[-1, :]
tensor([1., 1., 1., 0.])

Despite the error in 3D coordinates being small, I have found this fix to improve 3D reconstruction metrics quite a bit (~5% on my task).