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_labels is 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 prevents expand_labels from recreating a disconnected fragment.

Labels in exclude are left untouched. This is used by merge_cells to preserve a merge target whose components are intentionally disconnected (e.g. after merging a fragmented nucleus).

Return type:

int

Parameters:
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.

Return type:

bool

Parameters:
itasc.correction.erase_cell(seg, pos=None, *, label=None)[source]

Set all pixels of the label under pos (or label) to 0.

Return type:

bool

Parameters:
itasc.correction.expand_label_to_foreground(seg, foreground, label, *, max_distance)[source]

Expand label into connected foreground background pixels in-place.

Returns the number of newly labelled pixels. A max_distance of 0 means no distance cap.

Return type:

int

Parameters:
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). radius caps the hole depth: a hole is only filled when its deepest pixel lies within radius of the surrounding cell. radius <= 0 is a no-op.

Return type:

ndarray

Parameters:
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 to max_opening pixels 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. radius caps the hole depth as in fill_label_holes(). radius <= 0 or max_opening <= 0 is a no-op.

Return type:

ndarray

Parameters:
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.

Return type:

bool

Parameters:
itasc.correction.split_across(seg, img, pos_start, pos_end, *, new_label=None)[source]

Watershed-split the cell under pos_start using two seeds.

Return type:

bool

Parameters:
itasc.correction.split_draw(seg, positions, *, curlabel=None, new_label=None)[source]

Split a cell along a manually drawn line.

Return type:

bool

Parameters:
itasc.correction.swap_labels(seg, pos_a, pos_b)[source]

Swap the label values at the two click positions across the whole frame.

Return type:

bool

Parameters:

Submodules

labels

Label correction operations on a single (H, W) segmentation frame.