modosaic.services.boundary¶
modosaic.services.boundary ¶
BoundaryService ¶
Helpers for converting masks and dense maps into boundary maps.
coerce_hw_float
staticmethod
¶
coerce_hw_float(depth, convert_np=True)
Coerce a depth-like array to HxW float values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
ndarray
|
Depth-like array. |
required |
convert_np
|
bool
|
Whether to replace NaN and infinite values with zeros. |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Coerced |
Source code in modosaic/services/boundary.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
coerce_hw_float_with_mask
staticmethod
¶
coerce_hw_float_with_mask(depth)
Coerce a depth-like array to HxW float values and validity mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
depth
|
ndarray
|
Depth-like array with shape |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
Coerced float array and finite-value mask. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input cannot be interpreted as a 2D map. |
Source code in modosaic/services/boundary.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
coerce_mask_binary
staticmethod
¶
coerce_mask_binary(mask, expected_shape=None)
Coerce a mask-like array to a boolean mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
ndarray
|
Mask-like array. |
required |
expected_shape
|
tuple[int, int] | None
|
Optional expected |
None
|
Returns:
| Type | Description |
|---|---|
ndarray | None
|
Boolean mask, or |
Source code in modosaic/services/boundary.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
dilate_bool
staticmethod
¶
dilate_bool(x, radius)
Dilate a boolean map by a circular kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Boolean-like input map. |
required |
radius
|
int
|
Dilation radius in pixels. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Dilated boolean map. |
Source code in modosaic/services/boundary.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
masks_to_boundary
staticmethod
¶
masks_to_boundary(masks, expected_shape=None, thickness=1)
Convert instance masks to a combined boundary map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
masks
|
list[ndarray]
|
Instance masks. |
required |
expected_shape
|
tuple[int, int] | None
|
Optional expected output shape. |
None
|
thickness
|
int
|
Boundary thickness in pixels. |
1
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Boolean boundary map. |
Source code in modosaic/services/boundary.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |