MCPcopy Create free account
hub / github.com/computational-imaging/bacon / sample_surface

Method sample_surface

dataio.py:667–683  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

665 return coords
666
667 def sample_surface(self):
668 idx = np.random.randint(0, self.v.shape[0], self.num_samples)
669 points = self.v[idx]
670 points[::2] += np.random.laplace(scale=self.coarse_scale, size=(points.shape[0]//2, points.shape[-1]))
671 points[1::2] += np.random.laplace(scale=self.fine_scale, size=(points.shape[0]//2, points.shape[-1]))
672
673 # wrap around any points that are sampled out of bounds
674 points[points > 0.5] -= 1
675 points[points < -0.5] += 1
676
677 # use KDTree to get distance to surface and estimate the normal
678 sdf, idx = self.kd_tree.query(points, k=3)
679 avg_normal = np.mean(self.n[idx], axis=1)
680 sdf = np.sum((points - self.v[idx][:, 0]) * avg_normal, axis=-1)
681 sdf = sdf[..., None]
682
683 return points, sdf
684
685 def __getitem__(self, idx):
686 coords, sdf = self.sample_surface()

Callers 1

__getitem__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected