Segmentation tasks
Distance transform watershed task
plantseg.tasks.segmentation_tasks.dt_watershed_task(image: PlantSegImage, threshold: float = 0.5, sigma_seeds: float = 1.0, stacked: bool = False, sigma_weights: float = 2.0, min_size: int = 100, alpha: float = 1.0, pixel_pitch: tuple[int, ...] | None = None, apply_nonmax_suppression: bool = False, n_threads: int | None = None, is_nuclei_image: bool = False) -> PlantSegImage
Distance transform watershed segmentation task.
This function applies the distance transform watershed algorithm to segment the input image. It handles both standard boundary probability maps and nuclei images, with options for various preprocessing and segmentation parameters.
Parameters:
-
image
(PlantSegImage
) –The input image to segment.
-
threshold
(float
, default:0.5
) –Threshold value for the boundary probability maps. Defaults to 0.5.
-
sigma_seeds
(float
, default:1.0
) –Standard deviation for Gaussian smoothing applied to the seed map. Defaults to 1.0.
-
stacked
(bool
, default:False
) –If True and the image is 3D, processes the image slice-by-slice (2D). Defaults to False.
-
sigma_weights
(float
, default:2.0
) –Standard deviation for Gaussian smoothing applied to the weight map. Defaults to 2.0.
-
min_size
(int
, default:100
) –Minimum size of the segments to keep. Smaller segments will be removed. Defaults to 100.
-
alpha
(float
, default:1.0
) –Blending factor between the input image and the distance transform when computing the weight map. Defaults to 1.0.
-
pixel_pitch
(tuple[int, ...] | None
, default:None
) –Anisotropy factors for the distance transform. If None, isotropic distances are assumed. Defaults to None.
-
apply_nonmax_suppression
(bool
, default:False
) –Whether to apply non-maximum suppression to the seeds. Requires the Nifty library. Defaults to False.
-
n_threads
(int | None
, default:None
) –Number of threads to use for parallel processing in 2D mode. Defaults to None.
-
is_nuclei_image
(bool
, default:False
) –If True, indicates that the input image is a nuclei image, and preprocessing is applied accordingly. Defaults to False.
Returns:
-
PlantSegImage
(PlantSegImage
) –The segmented image as a new
PlantSegImage
object.
Source code in plantseg/tasks/segmentation_tasks.py
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 94 95 96 97 98 99 |
|
Cluster segmentation task
plantseg.tasks.segmentation_tasks.clustering_segmentation_task(image: PlantSegImage, over_segmentation: PlantSegImage | None = None, mode='gasp', beta: float = 0.5, post_min_size: int = 100) -> PlantSegImage
Agglomerative segmentation task.
Parameters:
-
image
(PlantSegImage
) –input image object
-
over_segmentation
(PlantSegImage
, default:None
) –over-segmentation image object
-
mode
(str
, default:'gasp'
) –mode for the agglomerative segmentation
-
beta
(float
, default:0.5
) –beta parameter
-
post_min_size
(int
, default:100
) –minimum size for the segments
Source code in plantseg/tasks/segmentation_tasks.py
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 |
|
Lifted Multicut task
plantseg.tasks.segmentation_tasks.lmc_segmentation_task(boundary_pmap: PlantSegImage, superpixels: PlantSegImage, nuclei: PlantSegImage, beta: float = 0.5, post_min_size: int = 100) -> PlantSegImage
Lifted multicut segmentation task.
Parameters:
-
boundary_pmap
(PlantSegImage
) –cell boundary prediction, PlantSegImage of shape (Z, Y, X) with values between 0 and 1.
-
superpixels
(PlantSegImage
) –superpixels/over-segmentation. Must have the same shape as boundary_pmap.
-
nuclei
(PlantSegImage
) –a nuclear segmentation or prediction map. Must have the same shape as boundary_pmap.
-
beta
(float
, default:0.5
) –beta parameter for the Multicut. A small value will steer the segmentation towards under-segmentation, while a high-value bias the segmentation towards the over-segmentation. (default: 0.5)
-
post_min_size
(int
, default:100
) –minimal size of the segments after Multicut. (default: 100)
Source code in plantseg/tasks/segmentation_tasks.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|