Work · Interactive explainer · Synthetic

Same Dice, Different Geometry

Equal overlap. Different connections. Move the same number of pixels and compare what stays connected.

Lucian Murgu · Synthetic demonstration · No model or patient data

Related research: the matched-overlap study

Change the arrangement.

Keep the counts equal. Watch the structure.

Choose a synthetic construction
A

Boundary changes

DICE—
Prediction AInteractive synthetic mask; numerical summary follows.
— region— holes

The foreground still forms one connected region.

B

A severed bridge

DICE—
Prediction BInteractive synthetic mask; numerical summary follows.
— regions— holes

A four-pixel cut separates the two regions.

40 × 24 pixels Shared synthetic reference

Color the diagrams by
32
864

Each mask misses 32 pixels and adds 32 elsewhere.

EXACTLY EQUAL OVERLAP

448 / 512=448 / 512

Large scores are rounded; these integer ratios match exactly.
  • Matched TP
  • Added FP
  • Missed FN
WHAT CHANGED

Move four missed pixels from the outer boundary into the narrow bridge. The two regions separate, while the overlap counts stay equal.

Inspect corresponding pixels: point or tap either diagram, or focus it and use the arrow keys. Escape clears the marker.

No pixel selected.

An overlap score counts agreement.

Let G be the reference foreground and P a proposed mask. A true positive is a pixel in both sets; a false positive belongs only to P; a false negative belongs only to G. Dice summarizes those counts in a single ratio.

D=2|P∩G||P|+|G|=2TP2TP+FP+FN

Select a term to highlight its pixels in both diagrams above.

Integer confusion counts · current construction
PixelsMask AMask B
Matched TP——
Added FP——
Missed FN——
Background agreement TN——
Why the counts force equal Dice

Each reference contains 256 foreground pixels. We remove k of them and add k background pixels. Every prediction therefore also has area 256, with TP = 256 − k and FP = FN = k. For both masks,

D=2(256−k)512=1−k256

At k = 32: 448 / 512 = 0.875.

The equality is exact before rounding. Rearranging those errors leaves the ratio unchanged because their coordinates never enter the formula. Agreement on background pixels, TN, is also absent from Dice.

Then ask what connects.

A connected region is a group of foreground pixels joined by an edge-to-edge path. The bridge and island examples change the number of these regions. The cavity example keeps a single region but creates an enclosed background hole.

Connected regions · β₀

1A2B

Enclosed holes · β₁

0A0B

We use 4-neighbor foreground connectivity and complementary 8-neighbor background connectivity. A background region is a hole only if it cannot reach the image boundary, including by a diagonal step. The reference always has one foreground region and no holes.

These counts answer specific structural questions. Matching them would not prove that two masks have the same shape, boundary accuracy or network organization. Nor is a connected mask automatically better: the intended object and task determine which structures should be present.

Overlap and structure describe different properties of the same mask. A useful evaluation makes both visible.
03 / REPRODUCE

A construction you can inspect.

Three recipes. Eight error budgets. No randomness. The same settings regenerate the same binary masks.

The download includes both masks, the reference, settings and integer counts as JSON.

Construction and measurement details

All masks occupy a 40-column by 24-row grid. Coordinates are zero-based, x increases rightward, and y increases downward. For the bridge recipe, two 10 × 12 blocks are joined by an 8 × 2 bridge. The severed version removes the central 2 × 2 portion of that bridge and allocates the remaining missed pixels to the outer boundary. Both masks add the same pixels below the blocks.

The island and cavity recipes use a 16 × 16 reference square. Boundary removals proceed from its top edge. Added pixels either extend the bottom edge or form a separate 8-column island. Cavity removals occupy an interior 8-column patch. The slider offers k = 8, 16, …, 64; each pair has exactly k missed and k added pixels.

The readable calculation source defines the full coordinate recipes. The JSON download contains every binary pixel, so the result can be checked without relying on that implementation. The formula is undefined when both masks are empty; this demonstration never generates that case.

Scope and references

This is an original synthetic teaching prototype, not a study, a trained segmentation model, or a proposed replacement metric. It makes no claims about the frequency or downstream impact of these configurations in real data. It covers binary 2D masks at one resolution.

  1. SciPy: Dice dissimilarity and its conversion to similarity. Reference for the count-based definition used here.
  2. scikit-image: Euler number and complementary connectivity conventions. Reference for the foreground/background neighborhood distinction.

Scope & limitations

  • Constructed 2D binary masks on one 40 × 24 grid; no experimental or clinical results.
  • Foreground uses 4-neighbor connectivity; background uses 8. Equal topology counts do not establish equal shape.

References

  1. SciPy: Dice dissimilarity and its conversion to similarity
  2. scikit-image: Euler number and complementary connectivity