@@ -62,8 +62,9 @@ skip_empty: true # skip background tiles
6262empty_threshold : null # null β Otsu
6363
6464# segmentation
65- method : " cellpose" # "cellpose" (GPU) or "threshold" (no GPU)
65+ method : " cellpose" # "cellpose" (GPU), "threshold" (no GPU), "custom"
6666label_name : " cellpose" # name under image.zarr/labels/
67+ dilate : 0 # optional: pixels to grow labels by, any method
6768cellpose :
6869 model : " cyto3"
6970 diameter : 30
@@ -77,6 +78,18 @@ pyramid_downscale: 2
7778sequential_labels : true # renumber labels to a contiguous 1..N
7879` ` `
7980
81+ !!! tip "Growing labels after segmentation"
82+ ` dilate: N` grows every label by `N` pixels once segmentation finishes,
83+ regardless of `method` (`cellpose`, `threshold`, or `custom`). It runs
84+ per-tile, before the overlap halo is trimmed and tiles are merged, so
85+ dilated labels still stitch correctly across tile boundaries β just make
86+ sure `overlap` covers the dilation amount plus the usual object-diameter
87+ halo. `0` (default) disables it. Under the hood this wraps whatever
88+ segmentation function `method` builds with
89+ [`patchworks.dilate_labels`](../api/postprocess.md); see [Custom
90+ segmentation function](#custom-segmentation-function) below for using it
91+ directly from Python instead of via config.
92+
8093!!! tip "Tile size vs runtime"
8194 `tile_shape : " auto" ` sizes each tile to your GPU's VRAM. Smaller tiles =
8295 more (faster) jobs; very large 3-D tiles are slow. Keep ` do_3D: false` (2-D
@@ -433,6 +446,29 @@ custom:
433446 sigma: 1.5
434447` ` `
435448
449+ # ## Growing labels afterwards (dilation)
450+
451+ To grow every label by a few pixels after segmentation β any method, not
452+ just `custom` β set `dilate : N` in the config (see the tip above), or wrap
453+ your function directly with
454+ [`patchworks.dilate_labels`](../api/postprocess.md) when calling the API
455+ yourself :
456+
457+ ` ` ` python
458+ from patchworks import tile_process, dilate_labels
459+ from patchworks.plugins.dog import dog_label_fn
460+
461+ fn = dog_label_fn(low_sigma=1.0, high_sigma=3.0, threshold=0.02)
462+ fn = dilate_labels(fn, iterations=2) # grow each label by 2 px, then run
463+ result = tile_process("image.zarr", fn, tile_shape=(1, 2048, 2048),
464+ overlap=8, write_to="labels.zarr")
465+ ` ` `
466+
467+ ` dilate_labels` wraps any `(tile) -> labels` function β the same contract
468+ described above β so it works with `dog_label_fn`, `cellpose_fn`, or your
469+ own `segment`. It dilates each tile's labels before the halo is trimmed and
470+ tiles are merged, so `overlap` must still cover the dilation amount.
471+
436472# ## Real example: StarDist 3-D, with model caching
437473
438474Heavy models must be loaded **once**, not per tile. On SLURM each tile is its
0 commit comments