Masks from meshes¶
Rebuild a segmentation mask from a compressed segmentation (mesh, seeds and image shape).
Every voxel centre is assigned to the region of space the mesh's triangles enclose it in, and each region is
named by the seed it holds (see dw3d.exact_voxelisation). The decision is exact and uses only the mesh's own
triangles, so the rebuilt mask does not depend on the NumPy or SciPy version, nor on the machine. It
approximates the original mask as closely as the mesh approximates the mask's interfaces; it is not a lossless
copy.
Sacha Ichbiah, 2021. Matthieu Perez, 2024. Herve Turlier's group, 2026.
reconstruct_mask_from_dict ¶
reconstruct_mask_from_dict(dict_mask: dict[str]) -> NDArray[np.int64]
Reconstruct a segmentation image from a saved dict of points, triangles, seeds coords and desired image shape.
Each voxel centre takes the label of the region of space the mesh's triangles enclose it in: two neighbouring centres are in the same region when the segment between them crosses no triangle, and a region takes the index of the seed it holds. A centre lying exactly on a triangle belongs to the region it enters when moved infinitesimally towards increasing index along axis 0, then 1, then 2 (towards decreasing index on the last voxel of an axis, so that a cell cut by the image box keeps its outermost voxels). A region holding no seed (a few centres cut off by a sliver thinner than a voxel) takes the label of the region it shares the most neighbouring centres with. Every test is exact, so the result does not depend on the NumPy or SciPy version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dict_mask
|
dict[str]
|
the dictionary |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int64]
|
NDArray[np.int64]: the rebuilt mask, of shape |
reconstruct_mask_from_saved_file_dict ¶
reconstruct_mask_from_saved_file_dict(filename_dict: str) -> NDArray[np.int64]
Reconstruct a segmentation image from a saved dict of points, triangles, seeds coords and desired image shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename_dict
|
str
|
a |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int64]
|
NDArray[np.int64]: the rebuilt mask, as |