jchibane / if-net

Implicit Feature Network (IF-Net) - Codebase
305 stars 59 forks source link

question about boundary_sampling #28

Closed LordLiang closed 3 years ago

LordLiang commented 3 years ago
def boundary_sampling(path):
    try:

        if os.path.exists(path +'/boundary_{}_samples.npz'.format(args.sigma)):
            return

        off_path = path + '/isosurf_scaled.off'
        out_file = path +'/boundary_{}_samples.npz'.format(args.sigma)

        mesh = trimesh.load(off_path)
        points = mesh.sample(sample_num)

        boundary_points = points + args.sigma * np.random.randn(sample_num, 3)
        grid_coords = boundary_points.copy()
        grid_coords[:, 0], grid_coords[:, 2] = boundary_points[:, 2], boundary_points[:, 0]

        grid_coords = 2 * grid_coords

        occupancies = iw.implicit_waterproofing(mesh, boundary_points)[0]

        np.savez(out_file, points=boundary_points, occupancies = occupancies, grid_coords= grid_coords)
        print('Finished {}'.format(path))
    except:
        print('Error with {}: {}'.format(path, traceback.format_exc()))

Hi, thank you for your excellent work! I have 2 questions about boundary_sampling, can you help me?

  1. Why do you exchange grid_coords[:, 0] and grid_coords[:, 2]? Do you want to rotate grid_coords ?
  2. grid_coords = 2 * grid_coords before this you normalize the range to [-0.5, 0.5] while you generate isosurf_scaled.off, now why do you change it to [-1, 1]
jchibane commented 3 years ago

Hi LordLiang,

this is the coordinate system which is needed for the 'grid_sample' function, see for example

https://github.com/jchibane/if-net/blob/master/models/local_model.py#L141

The grid sample function is used for trilinear interpolation when doing feature extraction from discrete deep feature grids at continuously sampled point coordinates.

Best, Julian