Data Processing Tasks
Image Preprocessing Tasks
Gaussian smoothing task
plantseg.tasks.dataprocessing_tasks.gaussian_smoothing_task(image: PlantSegImage, sigma: float) -> PlantSegImage
Apply Gaussian smoothing to a PlantSegImage object.
Parameters:
-
image
(PlantSegImage
) –input image
-
sigma
(float
) –standard deviation of the Gaussian kernel
Source code in plantseg/tasks/dataprocessing_tasks.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
Image cropping task
plantseg.tasks.dataprocessing_tasks.image_cropping_task(image: PlantSegImage, rectangle=None, crop_z: tuple[int, int] = (0, 100)) -> PlantSegImage
Crop the image based on the given rectangle and z-slices.
Parameters:
-
image
(PlantSegImage
) –The image to be cropped.
-
rectangle
(Optional
, default:None
) –Rectangle defining the region to crop.
-
crop_z
(tuple[int, int]
, default:(0, 100)
) –Z-slice range for cropping.
Returns:
-
PlantSegImage
(PlantSegImage
) –The cropped image.
Source code in plantseg/tasks/dataprocessing_tasks.py
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 115 116 117 118 |
|
Image rescale to shape task
plantseg.tasks.dataprocessing_tasks.image_rescale_to_shape_task(image: PlantSegImage, new_shape: tuple[int, ...], order: int = 0) -> PlantSegImage
Rescale an image to a new shape.
Parameters:
-
image
(PlantSegImage
) –input image
-
new_shape
(tuple[int, ...]
) –new shape of the image
-
order
(int
, default:0
) –order of the interpolation
Source code in plantseg/tasks/dataprocessing_tasks.py
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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
Image rescale to voxel size task
plantseg.tasks.dataprocessing_tasks.image_rescale_to_voxel_size_task(image: PlantSegImage, new_voxel_size: VoxelSize, order: int = 0) -> PlantSegImage
Rescale an image to a new voxel size.
If the voxel size is not defined in the input image, use the set voxel size task to set the voxel size.
Parameters:
-
image
(PlantSegImage
) –input image
-
new_voxel_size
(VoxelSize
) –new voxel size
-
order
(int
, default:0
) –order of the interpolation
Source code in plantseg/tasks/dataprocessing_tasks.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
Set image voxel size task
plantseg.tasks.dataprocessing_tasks.set_voxel_size_task(image: PlantSegImage, voxel_size: tuple[float, float, float]) -> PlantSegImage
Set the voxel size of an image.
Parameters:
Source code in plantseg/tasks/dataprocessing_tasks.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
Image pair operation task
plantseg.tasks.dataprocessing_tasks.image_pair_operation_task(image1: PlantSegImage, image2: PlantSegImage, operation: ImagePairOperation, normalize_input: bool = False, clip_output: bool = False, normalize_output: bool = False) -> PlantSegImage
Task to perform an operation on two images.
Parameters:
-
image1
(PlantSegImage
) –First image to process.
-
Image2
(PlantSegImage
) –Second image to process.
-
operation
(str
) –Operation to perform on the images.
-
normalize_input
(bool
, default:False
) –Normalize input images before processing.
-
clip_output
(bool
, default:False
) –Clip output values to the range [0, 1].
-
normalize_output
(bool
, default:False
) –Normalize output values to the range [0, 1].
Returns:
-
PlantSegImage
(PlantSegImage
) –New image resulting from the operation.
Source code in plantseg/tasks/dataprocessing_tasks.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
|
Label Postprocessing Tasks
Remove false positives task
plantseg.tasks.dataprocessing_tasks.remove_false_positives_by_foreground_probability_task(segmentation: PlantSegImage, foreground: PlantSegImage, threshold: float) -> PlantSegImage
Remove false positives from a segmentation based on the foreground probability.
Parameters:
-
segmentation
(PlantSegImage
) –input segmentation
-
foreground
(PlantSegImage
) –input foreground probability
-
threshold
(float
) –threshold value
Source code in plantseg/tasks/dataprocessing_tasks.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
Fix Over/Under segmentation task
plantseg.tasks.dataprocessing_tasks.fix_over_under_segmentation_from_nuclei_task(cell_seg: PlantSegImage, nuclei_seg: PlantSegImage, threshold_merge: float, threshold_split: float, quantile_min: float, quantile_max: float, boundary: PlantSegImage | None = None) -> PlantSegImage
Task to fix over- and under-segmentation of cells based on nuclear segmentation.
Parameters:
-
cell_seg
(PlantSegImage
) –Input cell segmentation as a PlantSegImage object.
-
nuclei_seg
(PlantSegImage
) –Input nuclear segmentation as a PlantSegImage object.
-
threshold_merge
(float
) –Threshold for merging cells, as a fraction (0-1).
-
threshold_split
(float
) –Threshold for splitting cells, as a fraction (0-1).
-
quantile_min
(float
) –Minimum quantile for filtering nuclei sizes, as a fraction (0-1).
-
quantile_max
(float
) –Maximum quantile for filtering nuclei sizes, as a fraction (0-1).
-
boundary
(PlantSegImage | None
, default:None
) –Optional boundary probability map for segmentation refinement.
Returns:
-
PlantSegImage
(PlantSegImage
) –Corrected cell segmentation as a PlantSegImage object.
Source code in plantseg/tasks/dataprocessing_tasks.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
|
Set biggest object as background task
plantseg.tasks.dataprocessing_tasks.set_biggest_instance_to_zero_task(image: PlantSegImage, instance_could_be_zero: bool = False) -> PlantSegImage
Task to set the largest segment in a segmentation image to zero.
Parameters:
-
image
(PlantSegImage
) –Segmentation image to process.
-
instance_could_be_zero
(bool
, default:False
) –If True, 0 might be an instance label, add 1 to all labels before processing.
Returns:
-
PlantSegImage
(PlantSegImage
) –New segmentation image with largest instance set to 0.
Source code in plantseg/tasks/dataprocessing_tasks.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
Relabel task
plantseg.tasks.dataprocessing_tasks.relabel_segmentation_task(image: PlantSegImage, background: int | None = None) -> PlantSegImage
Task to relabel a segmentation image contiguously, ensuring non-touching segments with the same ID are relabeled.
Parameters:
-
image
(PlantSegImage
) –Segmentation image to process.
Returns:
-
PlantSegImage
(PlantSegImage
) –New segmentation image with relabeled instances.
Source code in plantseg/tasks/dataprocessing_tasks.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
|