MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / build_point_grid

Function build_point_grid

utils/sam_utils/amg.py:179–186  ·  view source on GitHub ↗

Generates a 2D grid of points evenly spaced in [0,1]x[0,1].

(n_per_side: int)

Source from the content-addressed store, hash-verified

177
178
179def build_point_grid(n_per_side: int) -> np.ndarray:
180 """Generates a 2D grid of points evenly spaced in [0,1]x[0,1]."""
181 offset = 1 / (2 * n_per_side)
182 points_one_side = np.linspace(offset, 1 - offset, n_per_side)
183 points_x = np.tile(points_one_side[None, :], (n_per_side, 1))
184 points_y = np.tile(points_one_side[:, None], (1, n_per_side))
185 points = np.stack([points_x, points_y], axis=-1).reshape(-1, 2)
186 return points
187
188
189def build_all_layer_point_grids(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected