Numerical kernels for black-and-white RAW image processing.
The name is from φαιός (Greek, "dusky grey"), the term Aristotle uses in De Sensu for the intermediate colours between white and black.
A Rust crate with PyO3 bindings (phaios_core Python module). Pure
functions on f32 linear scene-referred (H, W, C) arrays — no I/O,
no GUI, no hidden state. Any front-end can build on it.
| Kernel | Description |
|---|---|
luminance_bw |
Standard B&W conversion: BT.601, BT.709 (default), BT.2020 |
channel_mixer_bw |
Arbitrary RGB weights in −2..+2 (infrared-like effects) |
color_filter_bw |
Wratten-style filter simulation (Yellow, Orange, Red, Green, Blue) |
zone_system |
Adams/Archer Zone System tone curve, 11 zones, Gaussian-blended |
local_contrast |
He–Sun–Tang guided filter for local contrast enhancement |
encode_srgb |
IEC 61966-2-1 sRGB transfer encoding (terminal stage) |
| Kernel | Description |
|---|---|
exposure |
Exposure compensation (EV stops) |
hsl_bw |
HSL-weighted B&W conversion (8 hue bands) |
film_grain |
Procedural film grain with explicit seed for determinism |
split_toning |
Parametric highlights/shadows toning |
vignette |
Radial vignette |
| Parametric tone curve | Arbitrary per-zone curve, independent of Zone System |
- Rust stable toolchain (
rustup default stable) - Python 3.12 or later (3.13 recommended for performance)
- maturin (installed via requirements-dev.txt)
# Clone and set up
git clone https://github.com/sdhdez/phaios-core
cd phaios-core
# Python environment
uv venv .phaios-venv
source .phaios-venv/bin/activate # Windows: .phaios-venv\Scripts\activate
uv pip install -r requirements-dev.txt
# Build and install the Python extension
maturin develop --release
# Run all tests
cargo test
pytest
# Run an example (writes examples/output/01_luminance.ppm)
cargo run --example 01_luminanceimport numpy as np
import phaios_core
# Linear f32 RGB image, shape (H, W, 3)
img = np.random.rand(1080, 1920, 3).astype(np.float32)
# B&W conversion — BT.709 luminance (default)
bw = phaios_core.luminance_bw(img) # shape (H, W, 1)
# Zone System tone curve
params = phaios_core.ZoneParams({5: 0.5}) # lift Zone V by half a stop
toned = phaios_core.zone_system(bw, params)
# Local contrast enhancement
lc_params = phaios_core.GuidedFilterParams(radius=8, eps=0.01)
enhanced = phaios_core.local_contrast(toned, lc_params, strength=0.5)
# sRGB encode (always last)
output = phaios_core.encode_srgb(enhanced)GNU General Public License v3.0 or later. See LICENSE.
All dependencies are MIT OR Apache-2.0, both compatible with GPLv3. Corresponding source is available at the repository URL above (satisfies GPLv3 §6(d)).
- docs/architecture.md — pipeline diagram, full mathematical derivations, algorithm citations.
- docs/ffi.md — Python↔Rust boundary contract, array layout, zero-copy rules, error handling.
The release workflow (.github/workflows/release.yml) builds wheels for
manylinux_2_17, Windows x86_64, and macOS arm64, then publishes
to PyPI and crates.io. Before tagging, you need:
crates.io
cargo loginlocally, or addCARGO_REGISTRY_TOKENto the GitHub repo's Settings → Secrets → Actions.
PyPI (OIDC trusted publishing — no token stored)
- Create the
phaios-coreproject on PyPI (first upload can usematurin publishlocally with an API token). - In the PyPI project: Manage → Publishing → Add a new publisher:
- Repository owner:
sdhdez - Repository name:
phaios-core - Workflow filename:
release.yml - Environment name:
pypi
- Repository owner:
Tagging
git tag v0.1.0
git push origin v0.1.0 # triggers release.yml