Skip to content

Reports and warnings (2D)

What dw2d's reconstruction did and what it found, as frozen records and warning classes.

The names follow dw3d's where the concept is the same (JunctionRelocationReport, EnclosedMediumWarning, UnresolvedCellWarning). The warning classes are dw2d's own, distinct from dw3d's classes of the same names: neither package imports the other at module level, so a filter on dw3d.EnclosedMediumWarning does not catch dw2d's (filter on both, or on their base class UserWarning).

EnclosedMediumWarning

Bases: UserWarning

A pocket of label 0 enclosed by cells (it touches no side of the image) is meshed as the outer medium.

dw2d has no enclosed-medium region yet (dw3d labels such a pocket as its own medium region): the pocket's triangles take label 0, so the mesh treats it as contact with the outer medium. The warning names each pocket.

UnresolvedCellWarning

Bases: UserWarning

A label of the mask is absent from the finished mesh: the reconstruction did not resolve that cell.

Usually a cell narrower than the point placement's min_distance, which no triangle of the watershed reached. The warning names each such label; MeshReconstructionAlgorithm.unresolved_cells lists them.

ThinMediumMarginWarning

Bases: UserWarning

A cell's edges lie on a side of the image that its pixels do not reach, and padding could not prevent it.

Emitted once per reconstruction, naming each such cell, the side, the cell's medium margin to it and why the side was not padded: a cell reaches it (it is a crop), padding is switched off, or the margin is already thin_margin_bound(min_distance) or more. The cell may have taken some of the medium between it and the side. The same name and meaning as dw3d's warning; see dw2d.thin_medium_margins.

JunctionRelocationReport dataclass

JunctionRelocationReport(mask_junctions: int, mesh_junctions: int, planned: int, fixed: int, moved: int, refused: dict[str, int] = dict(), unmatched_triples: int = 0, crossings_before: int = 0, crossings_after: int = 0, contacts_before: int = 0, contacts_after: int = 0, median_displacement_px: float | None = None)

What one 2D junction relocation did (dw2d.relocate_junction_vertices).

Attributes:

Name Type Description
mask_junctions int

junctions the mask gives (connected groups of pixel corners where three labels meet).

mesh_junctions int

mesh vertices where exactly three materials meet.

planned int

mesh junctions paired with a mask junction within the gate.

fixed int

planned moves dropped because the vertex is fixed (on the image border).

moved int

moves applied.

refused dict[str, int]

guard name -> number of moves that guard refused.

unmatched_triples int

material triples whose mesh and mask junction counts differ (left untouched).

crossings_before, crossings_after

proper crossings between edges before and after (never more after).

contacts_before, contacts_after

edge contacts before and after (never more after).

median_displacement_px float | None

median distance travelled by the applied moves, in pixels, or None if none moved.

as_dict

as_dict() -> dict[str, Any]

The report as a plain dictionary (for JSON records).

InterfaceProjectionReport dataclass

InterfaceProjectionReport(candidates: int, moved: int, not_converged: int, refused: dict[str, int] = dict(), crossings_before: int = 0, crossings_after: int = 0, contacts_before: int = 0, contacts_after: int = 0, median_displacement_px: float | None = None)

What one 2D interface projection did (dw2d.project_interface_vertices).

Attributes:

Name Type Description
candidates int

interface vertices eligible for a move (one interface, not a junction, not on the image border).

moved int

moves applied.

not_converged int

candidates whose Newton iteration did not converge (left in place).

refused dict[str, int]

guard name -> number of moves that guard refused.

crossings_before, crossings_after

proper crossings between edges before and after.

contacts_before, contacts_after

edge contacts before and after.

median_displacement_px float | None

median distance travelled by the applied moves, in pixels, or None if none moved.

as_dict

as_dict() -> dict[str, Any]

The report as a plain dictionary (for JSON records).

EnclosedMediumPocket dataclass

EnclosedMediumPocket(pixels: int, first_pixel: tuple[int, int], lining_labels: tuple[int, ...])

One 4-connected piece of label 0 that touches no side of the image.

Attributes:

Name Type Description
pixels int

its number of pixels.

first_pixel tuple[int, int]

its first pixel in raster order, (row, column).

lining_labels tuple[int, ...]

the labels 4-adjacent to it, ascending.