itasc.correction¶
- itasc.correction.clean_stranded_pixels(seg, min_size=4, *, exclude=None)[source]¶
Remove disconnected same-label fragments, keeping each label’s largest component.
Fragments are cleared and then
expand_labelsis used to propose a new label. The proposal is only accepted (written back) when the reassigned fragment pixels are 8-connected to an existing component of that same label — this preventsexpand_labelsfrom recreating a disconnected fragment.Labels in exclude are left untouched. This is used by
merge_cellsto preserve a merge target whose components are intentionally disconnected (e.g. after merging a fragmented nucleus).
- itasc.correction.draw_cell_path(seg, positions, *, curlabel=None, new_label=None, protected_mask=None)[source]¶
Draw a closed region from the user’s stroke and fill its interior.
- itasc.correction.erase_cell(seg, pos=None, *, label=None)[source]¶
Set all pixels of the label under pos (or label) to 0.
- itasc.correction.expand_label_to_foreground(seg, foreground, label, *, max_distance)[source]¶
Expand
labelinto connected foreground background pixels in-place.Returns the number of newly labelled pixels. A
max_distanceof 0 means no distance cap.
- itasc.correction.fill_label_holes(labels, radius=5)[source]¶
Fill background holes enclosed within a single cell.
A “hole” is a background component that does not touch the image border and is surrounded by exactly one label; it is filled with that label. Background bordered by two or more cells is an inter-cellular gap, not a hole, and is left untouched (so cells are never expanded into the space between them).
radiuscaps the hole depth: a hole is only filled when its deepest pixel lies withinradiusof the surrounding cell.radius <= 0is a no-op.
- itasc.correction.fix_label_semiholes(labels, radius=5, max_opening=3)[source]¶
Fill a hole enclosed by a single cell except for a narrow image-edge opening.
Like
fill_label_holes(), but for background that escapes to the image border through a thin gap (up tomax_openingpixels of edge contact). The opening’s edge flanks are ignored; the hole is filled only when its interior is enclosed by exactly one label, so cells are never expanded into inter-cellular gaps.radiuscaps the hole depth as infill_label_holes().radius <= 0ormax_opening <= 0is a no-op.
- itasc.correction.merge_cells(seg, pos_start, pos_end, *, label_a=None, label_b=None)[source]¶
Merge the cell at pos_start into the cell at pos_end.
- itasc.correction.split_across(seg, img, pos_start, pos_end, *, new_label=None)[source]¶
Watershed-split the cell under pos_start using two seeds.
- itasc.correction.split_draw(seg, positions, *, curlabel=None, new_label=None)[source]¶
Split a cell along a manually drawn line.
- itasc.correction.swap_labels(seg, pos_a, pos_b)[source]¶
Swap the label values at the two click positions across the whole frame.
Submodules
Label correction operations on a single (H, W) segmentation frame. |