Mask analysis¶
vertax.mask_analysis
Analyze masks (with no holes) to extracts a primitive mesh with vertices, edges, and faces.
segment ¶
segment(image: NDArray, save: bool = False, output_path: str = 'segmented_image.tiff', gpu: bool | None = None) -> NDArray
Segment given image using Cellpose.
The result will be imperfect and it will always be better if you provide directly the masks yourself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray
|
Image to segment. |
required |
save
|
bool
|
Whether to save the segmentation on disk. Defaults to False. |
False
|
output_path
|
str
|
Where to save the segmentation on disk. Defaults to "segmented_image.tiff". |
'segmented_image.tiff'
|
gpu
|
bool | None
|
Device used by Cellpose. |
None
|
Returns:
| Type | Description |
|---|---|
NDArray
|
The segmented image. |
refine ¶
refine(segmented_image: NDArray) -> NDArray
Grow segmented cells to avoid any holes in the mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segmented_image
|
NDArray
|
The segmentation with holes. |
required |
Returns:
| Type | Description |
|---|---|
NDArray
|
A mask suitable for what comes next, with no holes. |
mask_from_image ¶
mask_from_image(image: NDArray, gpu: bool | None = None) -> NDArray
Automatically create a mask from an image.
Note that the result will be imperfect and the result will always be better if you provide your own masks directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
NDArray
|
The original image. |
required |
gpu
|
bool | None
|
Device used by Cellpose. |
None
|
Returns:
| Type | Description |
|---|---|
NDArray
|
The corresponding mask. |
pad ¶
pad(mask: NDArray, save: bool = False, output_path: str = 'padded_image.tiff') -> NDArray
Pad a mask with mirrored reflections all around the mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
NDArray
|
Original mask. |
required |
save
|
bool
|
Whether or not to save the padded mask on disk. Defaults to False. |
False
|
output_path
|
str
|
Where to save it. Defaults to "padded_image.tiff". |
'padded_image.tiff'
|
Returns:
| Type | Description |
|---|---|
NDArray
|
The mask, padded around with mirrored reflections. |
find_vertices_edges_faces ¶
find_vertices_edges_faces(padded_mask: NDArray) -> tuple[NDArray, list[tuple[int, int]], list[list[int]]]
Construct rudimentary mesh from a labeled and padded mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
padded_mask
|
NDArray
|
The labeled padded mask. |
required |
Returns:
| Type | Description |
|---|---|
tuple[NDArray, list[tuple[int, int]], list[list[int]]]
|
tuple[NDArray, list[tuple[int, int]], list[list[int]]]: Vertices (2d positions), edges as list of couple of vertices indices, and faces as a list of vertices indices. |