Skip to content

Latest commit

 

History

History
11 lines (7 loc) · 1.43 KB

comb-distance-fields-build.md

File metadata and controls

11 lines (7 loc) · 1.43 KB

Comb scalar distance-map kernel

Both readers 0.2.4 embed this C kernel as WebAssembly. It implements the original forward/backward chamfer transforms and inverse-field adjustment. It contains no image identification, payload, header, RS/CRC, expected answer, photograph or lookup logic. The original JavaScript implementation remains as fallback.

python -m ziglang cc -target wasm32-freestanding -O3 -ffp-contract=off -fno-fast-math -nostdlib -Wl,--no-entry -Wl,--export=__heap_base -Wl,--export-memory -Wl,--strip-all -o distance.wasm comb-distance-fields.c

The wrapper copies nine float maps into scratch memory, calls the transform, and copies the maps back. Storage grows only when needed and is reused on later calls. Pixel classification and palette conversion stay in JavaScript. No fast math, SIMD or parallel reduction is used. The constants, scan order, intermediate double arithmetic and float storage remain the same. The module is base64-embedded; the HTML has no runtime dependency or network fetch.

17,737,686 sampled map values matched the original exactly, including random, white, black and checker images, small or awkward shapes and large SLOW resolutions. These sampled checks do not prove equality for all inputs. Whole-reader paired tests, failures, timeouts and limits are recorded on the progress page. Faster field construction is not a new recovery claim. The backup includes builders, source templates, wrappers and tests.