Skip to main content

Module validate

Module validate 

Source
Expand description

Post-growth validation for a labelled square grid.

Two independent checks run over the labelled set:

  1. Line collinearity. For every row (j = const) and column (i = const) with ≥ line_min_members labelled members, fit a least-squares line in pixel space and flag any member whose perpendicular residual exceeds line_tol_rel × cell_size.

  2. Local-H residual. For every labelled corner with ≥ 4 non-collinear labelled neighbors in (i, j)-space, fit a 4-point local homography from the 4 grid-closest neighbors, predict the corner’s pixel position, and measure the residual. Corners whose residual exceeds local_h_tol_rel × cell_size are flagged.

Flags are combined via the attribution rules below into a blacklist of indices into the input slice:

  • A corner flagged in ≥ 2 lines is the outlier.
  • A corner with a large local-H residual (> 2 × local_h_tol) AND at least one line flag is the outlier.
  • A corner with a local-H flag but NO line flag, where at least one of its 4 base neighbors has ≥ 1 line flags, blames the worst- line-flagged base instead (the base is the outlier).
  • Otherwise (isolated local-H flag with no supporting evidence), defer — no blacklist entry in this iteration.

The caller is expected to re-run the seed/grow/validate loop after updating its blacklist.

§Pattern-agnostic

This module has no dependency on chessboard-specific vocabulary (parity, axis clusters, label enums). Any caller that can produce a (corner_index, pixel_position, grid_coord) slice can use it. Consumers that carry per-stage metadata should pre-filter to the “labelled” subset before calling.

Structs§

LabelledEntry
A single labelled corner fed into validate: its caller-chosen index (carried back in ValidationResult::blacklist), its pixel position, and its integer grid coordinate.
ValidationParams
Tolerances for the validation pass.
ValidationResult
Outcome of one validation pass.

Functions§

validate
Run both validation passes and produce a blacklist.