Segmentation Utilities#
This is a collection of wrapper functions for omnipose.
Run the specified omnipose model on the input image(s)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
np.array
|
The input image(s) to segment. If a single image is provided, it should be a 2D array. If multiple images are provided, they should be a 3D array with shape (n_images, height, width). |
required |
model_name
|
str
|
The name of the model to use. |
required |
gpu_option
|
bool
|
Whether to use the GPU for segmentation. |
required |
chans
|
tuple or None
|
The channels to use for segmentation. If None, the first channel will be used. |
None
|
filter_options
|
dict
|
A dictionary containing the filter options for the segmentation. Related to the omnipose package. See this link for more info: https://omnipose.readthedocs.io/examples/mono_channel_bact.html#run-segmentation |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
masks |
np.ndarray
|
The segmented masks. If a single image is provided, it will be a 2D array. If multiple images are provided, it will be a 3D array with shape (n_images, height, width). |
flows |
np.ndarray
|
The flow outputs. If a single image is provided, it will be a 2D array. If multiple images are provided, it will be a 3D array with shape (n_images, height, width). |
Source code in src/micromorph/segmentation/segmentation_tools.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
Function to filter the segmentation mask basaed on basic morphological criteria such as area, length and width.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
np.array
|
The mask to filter. If a single mask is provided, it should be a 2D array. If multiple masks are provided, they should be a 3D array with shape (n_masks, height, width). |
required |
options
|
dict
|
A dictionary containing the filter options for the segmentation. The options are: - min_area: The minimum area of the bacteria. - max_area: The maximum area of the bacteria. - min_length: The minimum length of the bacteria. - max_length: The maximum length of the bacteria. - min_width: The minimum width of the bacteria. - max_width: The maximum width of the bacteria. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
filtered_mask |
np.ndarray
|
The filtered mask. If a single mask is provided, it will be a 2D array. If multiple masks are provided, it will be a 3D array with shape (n_masks, height, width). |
Source code in src/micromorph/segmentation/segmentation_tools.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |