Skip to main content

boundary_density

Function boundary_density 

Source
pub fn boundary_density(img: &CaptureImage, bg: [u8; 4], eps: u8) -> f32
Expand description

Perimeter of the lit figure over its area: the share of lit pixels having at least one unlit 4-neighbour (0.0..=1.0) — “is the lit set a solid mass, or does it have interior?”

This is the second term of the flatness gate (ADR-0128, settled by ADR-0130). tonal_flatness asks whether the figure has any tonal structure and convicts a two-ink print for having exactly two tones, which is what that idiom is; this asks the orthogonal question, and a picture is called a blot only when both say so.

A solid mass carries only its rim on the boundary and reads low; a hatched, stroked or tiled figure is almost all rim and reads near one. Both halves of that are claims at one capture size and not properties of the figure — the resolution paragraph below is what qualifies them, and a solid mass small enough reads 1.0000 exactly as a hatched one does. The denominator is the lit area, not the frame’s, which is what keeps the statistic asking one question: normalizing by frame area would make a frame score higher merely for having more lit material, and how much is lit is coverage, another term of the same gate.

Frame edges count as unlit, so a figure running off the frame counts that as boundary. The alternative — edges as lit — would let a fullscreen fill read as having no perimeter at all, which is the one answer this statistic must not give.

It is bound to the capture’s resolution and is comparable only at a fixed one. Perimeter over area goes as ~1/L in the capture’s linear size, so the same scene at 192×192 reads roughly half what it reads at 96×96, and a solid disc of radius r px reads about 2/r — which is why a 4×4 solid block reads 1.0000 and a large one does not. Every floor derived from this statistic is measured at the sanity suite’s 96×96 capture, and neither the numbers nor the ordering carry to another size.

It reads pixel-scale perimeter, so a ragged mass defeats it: a particle blot noisier than the fixture the threshold was measured on has more perimeter per lit pixel than a composition does. That is the known decay mode and ADR-0130 records it as accepted rather than solved.

0.0 for a frame with no lit pixels — the convention tonal_flatness uses, and coverage is the metric that already convicts an empty picture.