feat(classify): add panel_density and wire form-scan into score slate (MK-16) #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/classify-panel-density-MK-16"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds the
panel_densityfeature tomonkey image classifyand wiresImageClass::FormScaninto thescore()candidates slate (MK-16, follow-up to MK-7 / MK-14 / MK-18).panel_densitydownscales luma to a fixed 256x256 buffer (shared witheffective_palette), quantizes to 4 tones usingpanel_luma_lo/panel_luma_hi, connected-component labels the mid-tone mask, and emits the area-fraction of components whose individual area is at leastpanel_min_area. Otsu eta is recomputed over the complement of the panel mask asnon_panel_bimodality.form_scan = soft_ge(panel_density, panel_density_min) * soft_ge(non_panel_bimodality, bimodality_binary) * edges_text * low_sat * (1 - color). The MK-16 spec formula did not includeedges_text; without it theclassifies_mono_photosynthetic (smooth black-to-white gradient) falsely lands in FormScan because the gradient is one huge mid-tone connected component and its non-panel set is two trivially-bimodal extremes. Requiring text-density edges separates a real form from a gradient; the deviation is documented inline at the score site.monkey image classify --probeemits per-component panel diagnostics on stderr (index, area, area_frac, mean_luma, bbox) followed bypanel-density:andnon-panel-bimodality:. The data is already computed byextract_features, so the flag is essentially free.classify.tomlgains the five new keys (panel_density_min,panel_min_area,panel_luma_lo,panel_luma_hi,soft_scale_panel) with their initial values flagged as assumptions to revise against fixtures.The
form-scan.tomlrecipe stays a passthrough; the panel-aware processing chain is a separate MK issue.Test plan
just check(fmt + clippy-D warnings+ cargo build + cargo test + Docker builder stage) passes.classifies_form_scansynthetic (800x600 white page with text bands + one 35% x 30% mid-grey panel) classifies asform-scanwithpanel_density >= 0.05.classifies_color_photo,classifies_mono_photo,classifies_binary_scan,letter_aspect_mono_scan_is_binary_not_receipt,classifies_halftone,ceiling_rejects_perfect_periodic_grid,classifies_receipt,classifies_screenshot,classifies_graphic,line_art_is_not_halftone,solid_colour_is_unknown,checkerboard_is_not_color_photo,confidence_in_unit_interval,embedded_config_parses.tests/fixtures/classify/form-scan/: all 5 fixtures classify asform-scanwith confidence >= 0.30 andpanel_density >= 0.05. The fixtures are locally staged (not committed), so I cannot run this from inside CI.tests/fixtures/classify/{binary-scan,receipt,color-photo}/: rates unchanged.Closes MK-16.