Coloring (photo to coloring page and coloring book) - fotojockovic.com/coloring ============================================================================= Turns photos into printable coloring pages and personalised coloring books (PDF, PNG, SVG), and lets you colour them in on screen. Everything runs in the browser; no photo leaves the device. Our own work (MIT licence): - The line-art engine, written in Rust and compiled to WebAssembly (src-rs/, built into cp.wasm, run in worker.js). The crate has no third-party dependencies. It contains: texture removal (rolling guidance on a recursive domain-transform filter), a texture-energy map that weakens edges inside grass, foliage, fur and knitwear, marker-based watershed over-segmentation on a chroma-weighted edge map, greedy region-adjacency merging (boundary contrast, colour, size, subject and person classes, extra merging of skin shading), clean-up of regions too small or too thin to colour, curvature-flow smoothing of region labels, shared-boundary tracing on the pixel-crack lattice (so every shape is closed and every line is drawn once), Gaussian chain smoothing and curve fitting, line classes (subject outline, main, inner, background), detail strokes from a Hessian ridge detector and structure edges (non-maximum suppression, hysteresis, Zhang-Suen thinning, tapered outlines), black eyes/noses with highlights from a dark-blob detector, and faces drawn from face-mesh landmarks (eyelids, irises clipped to the eye opening, pupils with highlights, brows, nose, lips). src-rs/src/geom.rs and src-rs/src/fit.rs are copied from our own Vectorize tool (/static/tools/vectorize/src-rs, MIT): Bezier helpers and the curve fitter. - page.js: page layout, frames, patterns (stars, hearts, flowers, bubbles, mandala, zentangle, hexagons), sceneries (meadow, sea, space, party), bubble-letter titles, canvas renderer, SVG writer and PDF writer. - paint.js: colouring on screen (scanline flood fill bounded by the drawn lines, crayon/marker/glitter/rainbow textures, brush, eraser, undo). app.js, ml.js, index.html, the texts and translations, the icons. - Sample-derived images in demo/ (hero_b.png and the coloring pages) are output of this tool. Published methods the engine builds on (ideas only; no code was copied): - E. S. L. Gastal, M. M. Oliveira, "Domain Transform for Edge-Aware Image and Video Processing", SIGGRAPH 2011. - Q. Zhang, X. Shen, L. Xu, J. Jia, "Rolling Guidance Filter", ECCV 2014. - F. Meyer, "Topographic distance and watershed lines", Signal Processing 1994 (flooding watershed). - R. Achanta et al., "SLIC Superpixels", TPAMI 2012 (optional SLIC path, used only for comparison). - B. Ottosson, "A perceptual color space for image processing" (OKLab), 2020 - public domain formulas. - P. J. Schneider, "An Algorithm for Automatically Fitting Digitized Curves", Graphics Gems, 1990 (in fit.rs). - T. Y. Zhang, C. Y. Suen, "A fast parallel algorithm for thinning digital patterns", CACM 1984. - C. Steger, "An unbiased detector of curvilinear structures", TPAMI 1998 (Hessian ridge idea). - G. Borgefors, "Distance transformations in digital images", 1986 (3-4 chamfer distance); P. Felzenszwalb, D. Huttenlocher, "Distance Transforms of Sampled Functions", 2012. - J. Canny, "A computational approach to edge detection", TPAMI 1986 (non-maximum suppression, hysteresis). - PDF 1.4 Reference (Adobe) for the PDF writer, including transparency groups and the Multiply blend mode. Third-party code and models shipped to the browser (loaded only for the visitor's own photos; the demos ship with precomputed masks and do not load them): 1. MediaPipe Tasks Vision 1.1.1 (vision_bundle.js, vision_wasm_internal.js/.wasm and the no-SIMD variants), Google LLC - Apache License 2.0. https://github.com/google-ai-edge/mediapipe , npm @mediapipe/tasks-vision. Files unchanged (copied from /static/tools/1860/mp, which documents the source). Licence: mp/LICENSE-Apache-2.0.txt 2. Models, all Google, Apache License 2.0 (checked 2026-10-16): - mp/face_landmarker.task: Face Landmarker bundle = BlazeFace (short range) + Face Mesh V2 (+ blendshapes). Model cards "MediaPipe BlazeFace Model Card (Short Range)" and "Model Card MediaPipe Face Mesh V2": "LICENSED UNDER Apache License, Version 2.0". https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/latest/face_landmarker.task - mp/selfie_multiclass_256x256.tflite: Selfie Multiclass segmentation (background, hair, body skin, face skin, clothes, others). Model card "Model Card Multiclass Segmentation": "LICENSED UNDER Apache License, Version 2.0". https://storage.googleapis.com/mediapipe-models/image_segmenter/selfie_multiclass_256x256/float32/latest/selfie_multiclass_256x256.tflite - mp/magic_touch.tflite: MagicTouch interactive segmenter (one tap -> object mask). Model card "Model Card MagicTouch": "LICENSED UNDER Apache License, Version 2.0". https://storage.googleapis.com/mediapipe-models/interactive_segmenter/magic_touch/float32/latest/magic_touch.tflite - mp/efficientdet_lite0.tflite: EfficientDet-Lite0 object detector (int8), trained on COCO 2017. Licence: Apache 2.0 as listed for "tensorflow/efficientdet" tfLite lite0 variations on Kaggle Models (TensorFlow Hub's successor). The MediaPipe file is this model with MediaPipe metadata (same weights; inferred from the MediaPipe documentation). https://storage.googleapis.com/mediapipe-models/object_detector/efficientdet_lite0/int8/latest/efficientdet_lite0.tflite Training data of these models (COCO and Google's own data sets) is documented in their model cards; we use the published weights under their Apache 2.0 licences. 3. opentype.js 2.0.0, Frederik De Bleser and contributors - MIT. https://github.com/opentypejs/opentype.js Reads the title font to turn the letters into vector outlines. Copied from /static/tools/stars/opentype.js. MIT licence: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. 4. Font fonts/comfortaa-700.ttf: Comfortaa by Johan Aakerlund (and contributors), SIL Open Font License 1.1 (fonts/OFL-Comfortaa.txt). A static Bold (700) instance made with fontTools from the variable font in github.com/google/fonts (ofl/comfortaa); Latin, Cyrillic and Greek, so names in all 15 languages work. 5. Interface fonts, loaded from Google Fonts, SIL Open Font License 1.1: Inter Tight (Rasmus Andersson et al.), Instrument Serif (Instrument). Sample photos (demo/), Wikimedia Commons, each released under CC0 1.0 (public domain dedication), resized (licence data checked through the Commons API, 2026-10-16): - dog.jpg, dog_t.jpg, hero_a.jpg: "Young English Pointer lying on the grass.jpg", Joselodos, CC0. https://commons.wikimedia.org/wiki/File:Young_English_Pointer_lying_on_the_grass.jpg - couple.jpg, couple_t.jpg: "Elderly Couple Eating.jpg", Bill Branson, CC0. https://commons.wikimedia.org/wiki/File:Elderly_Couple_Eating.jpg - cottage.jpg, cottage_t.jpg: "Pigeon House Cottage, Eastbury, Berkshire.jpg", Mertbiol, CC0. https://commons.wikimedia.org/wiki/File:Pigeon_House_Cottage,_Eastbury,_Berkshire.jpg - *.cls.png, *.faces.json: subject classes and face landmarks of these photos, computed with the models above. Shared helpers /static/tools/common/i18n.js, rail.js and sheets.js: our own. Used only to build and test, never shipped to the browser: Rust and cargo (MIT/Apache-2.0); binaryen (Apache-2.0) for wasm-opt; fontTools (MIT) to make the static font instance; Pillow (MIT-CMU) and puppeteer-core (Apache-2.0) for tests. No GPL code is shipped. Every machine-learning model shipped is under the Apache License 2.0. Self-hosted web fonts (2026-10-19): Inter Tight, Instrument Serif. SIL Open Font License 1.1. The woff2 files are the ones Google Fonts serves (latin, latin-ext, cyrillic, greek subsets where the family has them), stored on our own server under /static/tools/common/fonts// with each family's licence text (OFL.txt) next to them; stylesheet /static/tools/common/fonts/ui.css. No font request goes to Google.