# InkStudio (墨印工坊) — Complete Technical Specification & Architecture Reference > Canonical URL: https://ink.llmland.io/ > Standalone FAQ URL: https://ink.llmland.io/faq/ > Supported Locales: zh-Hans (https://ink.llmland.io/zh-Hans/), zh-Hant (https://ink.llmland.io/zh-Hant/), en (https://ink.llmland.io/en/), ja (https://ink.llmland.io/ja/) > Runtime Stack: Pure Client-Side HTML5 + ES6 + Rust (`wasm32-unknown-unknown`, 0 external crates, 81 KB) + Web Crypto API SHA-256 Attestation ## 1. Executive Summary InkStudio is a browser-based computational photography and document image processing workbench built to extract transparent 32-bit RGBA signatures, red seals, and brush calligraphy from uneven smartphone photos. Every mathematical operation executes locally inside WebAssembly linear memory with 0 bytes transmitted to external servers. ## 2. Core Rust + WebAssembly Algorithms (`ink_studio_wasm`) ### 2.1 Dual-Scale 2D Integral Image Illumination Envelope (`IntegralImage`) - Computes 64-bit summed-area tables across R, G, B, and Luminance channels in a single pass. - Evaluates upper illumination envelopes across base radius `R` (8–100 px) and `2R` in O(1) time per pixel so thick brush strokes and solid seals never self-darken their local background reference. ### 2.2 Beer-Lambert Optical Density Alpha Unmixing & Foreground De-Haloing - Models pixel intensity as `I(x,y) = alpha * F(x,y) + (1 - alpha) * B(x,y)`. - Solves continuous sub-pixel alpha via smoothstep + gamma mapping and recovers true unmixed ink color `F = (I - (1 - alpha)B) / alpha`, completely eliminating white paper halos on dark backgrounds. ### 2.3 Red Seal De-Texting & Directional Morphological Inpainting - Separates vermilion seal chromaticity from dark achromatic contract text (`abs_l > 0.28` and `raw_red_diff < 0.14`). - Runs 1–12 iterations of directional 8-neighbor weighted diffusion from valid surrounding seal pixels to reconstruct continuous seal strokes where black text crossed. ### 2.4 Exact 2D Euclidean Signed Distance Field (SDF) Stroke Morphing (`edt_2d`) - Implements Felzenszwalb & Huttenlocher O(N) separable 1D parabolic lower-envelope distance transforms for interior and exterior masks. - Offsets the signed distance field by `[-2.5 px, +4.5 px]` with nearest-foreground color propagation. ### 2.5 Contour Tracing & Quadratic Bézier SVG Vectorizer (`wasm_trace_svg`) - Extracts directed pixel-grid boundary loops, simplifies closed polygons via midpoint-split Ramer-Douglas-Peucker (`epsilon = 0.4..6.0`), and emits smooth `` SVG documents.