From 611ae14b1a185d02f9cdded27e65f6a793d7282d Mon Sep 17 00:00:00 2001 From: gabriel Date: Wed, 7 Oct 2026 13:21:00 +0200 Subject: [PATCH 1/2] chore: include MIT notice for OpenDithering-derived DBS code dbs.rs is ported from OpenDithering's src/dithering/dbs.ts (MIT, Copyright (c) 2026 Guy Sie). MIT requires the copyright and permission notice in copies or substantial portions, so include it in full at the top of dbs.rs and in a new THIRD_PARTY_NOTICES.md that records the source file and commit. --- THIRD_PARTY_NOTICES.md | 33 +++++++++++++++++++++++++++++++++ packages/rust/core/src/dbs.rs | 32 ++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 THIRD_PARTY_NOTICES.md diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..cab0504 --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,33 @@ +# Third-party notices + +This project includes code derived from the following third-party software. + +## OpenDithering + +- **Source:** https://github.com/guysie/opendithering (`src/dithering/dbs.ts`, commit `2f579b9`) +- **Used in:** `packages/rust/core/src/dbs.rs` (Direct Binary Search refinement), ported to Rust and modified +- **License:** MIT + +``` +MIT License + +Copyright (c) 2026 Guy Sie + +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, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` diff --git a/packages/rust/core/src/dbs.rs b/packages/rust/core/src/dbs.rs index 7a34b5d..24d92cf 100644 --- a/packages/rust/core/src/dbs.rs +++ b/packages/rust/core/src/dbs.rs @@ -1,3 +1,26 @@ +// Portions of this file are derived from OpenDithering's `src/dithering/dbs.ts` +// (https://github.com/guysie/opendithering), used under the MIT License: +// +// Copyright (c) 2026 Guy Sie +// +// 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, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + //! Colour Direct Binary Search (DBS): iterative refinement of an already-dithered image. //! //! Minimises perceived error `E = Σ_ch Σ_m ((p_ch ∗ e_ch)(m))²`, where `e = halftone − target` @@ -8,16 +31,17 @@ //! //! Each pass visits every pixel (raster order within tiles; tiles run in parallel, see //! `dbs_refine`) and tries changing it to every other ink and swapping it with each differing -//! 8-neighbour, applying the move with the largest decrease in `E`. Trial cost is O(1) via the cached correlation `c_pe = c_pp ⋆ e`, where -//! `c_pp = p ⋆ p` is the blur's autocorrelation; an accepted move updates `c_pe` over the -//! footprint of `c_pp` only. +//! 8-neighbour, applying the move with the largest decrease in `E`. Trial cost is O(1) via +//! the cached correlation `c_pe = c_pp ⋆ e`, where `c_pp = p ⋆ p` is the blur's +//! autocorrelation; an accepted move updates `c_pe` over the footprint of `c_pp` only. //! //! Eye-model blurs are stored as full 2-D tables and `c_pp` is derived from them generically, //! so a non-separable model (e.g. the exponential CSF's spatial kernel) can be swapped in. //! //! References: Analoui & Allebach (1992); Lieberman & Allebach (1997); Agar & Allebach (2005); //! Flohr, Kolpatzik et al. (1993, YyCxCz); Kolpatzik & Bouman (1992, CSF constants); -//! Mullen (1985). Ported from OpenDithering's `dbs.ts` (MIT, © Guy Sie). +//! Mullen (1985). Ported from OpenDithering's `dbs.ts` by Guy Sie (MIT; see the notice above +//! and `THIRD_PARTY_NOTICES.md`). use rayon::prelude::*; From 24a6fa820f67aaff52569cbf7bf1f467e61c4ce1 Mon Sep 17 00:00:00 2001 From: gabriel Date: Wed, 7 Oct 2026 13:21:01 +0200 Subject: [PATCH 2/2] docs: list OpenDithering under Related Projects --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 304b0e3..c1adb3f 100644 --- a/README.md +++ b/README.md @@ -129,3 +129,4 @@ cargo test --workspace - **py-opendisplay**: [Python library for OpenDisplay BLE e-paper devices](https://github.com/OpenDisplay-org/py-opendisplay) - **hass-eink-dashboard**: [Home Assistant custom component that renders e-ink dashboard images for Kindle, TRMNL, and OpenDisplay devices.](https://github.com/cryptomilk/hass-eink-dashboard) +- **OpenDithering**: [Browser tool by Guy Sie for previewing dithering on e-paper palettes and uploading images to OpenDisplay devices over Bluetooth](https://guysie.github.io/opendithering/) ([source](https://github.com/guysie/opendithering)). An independent implementation, so results differ from this library; our DBS refinement is ported from it.