Skip to main content

focal

Image processing in C++20 with a zero-copy NumPy interface.

import focal

img = focal.imread("photo.jpg")          # linear float32, (h, w, c)
img = focal.exposure(img, 0.5)           # half a stop brighter
img = focal.gaussian_blur(img, 2.0)
focal.imwrite("out.png", img)            # encodes back to sRGB

Design

Everything is a view. The core type is a non-owning {pointer, dtype, shape, strides} struct, so a crop, a single channel, and a NumPy array handed over from Python are all the same type, and none of them copy. Strides are in bytes, matching NumPy exactly, so wrapping an incoming array is copying six integers.

Nothing converts silently. Array arguments are declared .noconvert(), so passing a float64 or non-contiguous array raises TypeError instead of quietly costing a full-size copy. Converting is the caller's decision.

Filtering happens in linear light. imread decodes sRGB to linear float32 and imwrite encodes back. Blurring or resizing gamma-encoded values darkens the result — on a synthetic test chart, a σ=3 blur done in gamma space came out 29% darker than the same blur done correctly, with individual pixels off by 74/255.

What's here

I/O imread, imwrite — PNG, JPEG, BMP, TGA via stb
Point ops gamma, exposure, brightness_contrast, invert, clip, blend, apply_lut
Filtering gaussian_blur (separable)
Sampling sample — nearest and bilinear, border-aware
Color srgb_to_linear, linear_to_srgb

Border modes (clamp, reflect, reflect101, wrap, constant) are shared by every spatial op and match scipy.ndimage's semantics.

Install

pip install focalpy

Building from source needs a C++20 compiler and CMake:

git clone https://github.com/edisons3608/focal
cd focal
pip install -e . --no-build-isolation
pytest

Status

Early. The API will change. Tests compare against scipy.ndimage and PIL where an oracle exists.

License

MIT. Bundles stb (public domain).

Metadata

Release files for focalpy 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for focalpy 0.0.1
File Size Uploaded Provenance Actions
focalpy-0.0.1.tar.gz 111.6 kB With provenance Details for focalpy-0.0.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for focalpy 0.0.1
File Actions
focalpy-0.0.1-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for focalpy-0.0.1-cp312-abi3-win_amd64.whl
focalpy-0.0.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for focalpy-0.0.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
focalpy-0.0.1-cp312-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for focalpy-0.0.1-cp312-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
focalpy-0.0.1-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details for focalpy-0.0.1-cp312-abi3-macosx_11_0_arm64.whl
focalpy-0.0.1-cp312-abi3-macosx_10_15_x86_64.whl CPython 3.12 abi3 macOS 10.15+ x86-64 Details for focalpy-0.0.1-cp312-abi3-macosx_10_15_x86_64.whl

Total release size: 1.1 MB

Release files / focalpy-0.0.1.tar.gz

Download URL focalpy-0.0.1.tar.gz
Size 111.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e286cd7f34064cc0409058b0f2116c915579753ebc7252fc2fb29c80496088a9
BLAKE2b-256 checksum
How to use checksums
747891deb1d31b1273f7f11fc2e1d7efc64ebe5f99f59fa3f8b28908fa77f6a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / focalpy-0.0.1-cp312-abi3-win_amd64.whl

Download URL focalpy-0.0.1-cp312-abi3-win_amd64.whl
Size 340.1 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2be0cf2da8797ce0e58d4368f4624ffbaafb57b4fa9bd2377d2cd9221f85db1c
BLAKE2b-256 checksum
How to use checksums
0f063097b4c2e9fb6e23aba9ae08f8181b63130dfd96ef2f02f452cbda9b5bd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / focalpy-0.0.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL focalpy-0.0.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 207.5 kB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
4efc8107fb6de740ac578d27c021a1afb28dd3f648b3a372b55aa5d8d13c05ab
BLAKE2b-256 checksum
How to use checksums
25e73499b394045abaf398f28f9831ac5d1441e9d8536a04309647970473ace2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / focalpy-0.0.1-cp312-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL focalpy-0.0.1-cp312-abi3-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 181.8 kB
Tags CPython 3.12 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
02a523d96fbe6144454cc06f4a1c51f2d3612af2f4af0a841310eba5d3a46519
BLAKE2b-256 checksum
How to use checksums
e79399f76ed0102fc5452a13e4dbc3f43e286c2cf566fda1c1acf58b107c41c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / focalpy-0.0.1-cp312-abi3-macosx_11_0_arm64.whl

Download URL focalpy-0.0.1-cp312-abi3-macosx_11_0_arm64.whl
Size 140.4 kB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1a0d4fb1d37ab77bf297c8de5f5641fb19c91fd8ed4d99f6f745b04e99ddefc6
BLAKE2b-256 checksum
How to use checksums
d00123ec27e04c2716b54bee0f7d1da2f527beb6ef1492ab094893a6a4430f1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / focalpy-0.0.1-cp312-abi3-macosx_10_15_x86_64.whl

Download URL focalpy-0.0.1-cp312-abi3-macosx_10_15_x86_64.whl
Size 154.6 kB
Tags CPython 3.12 abi3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
b923d79b7e3691902c3f3ba93eb24b3f7245a61cf092ce7c983ada5a8ea32094
BLAKE2b-256 checksum
How to use checksums
1b53983978ef06ac597712436e703d254f1cda56c976baf01188f2a1b7ce8860
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Security for focalpy 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for focalpy-0.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page