Skip to main content

pixelmap-python

PyPI Python versions License: MIT

Dense image correspondence: given two photographs of the same scene, work out where each pixel of the first one went in the second.

Python bindings for the pixelmap Rust crate, the reference implementation of the PIXELMAP framework (white paper). Every cell of an affine correspondence grid acts as an autonomous agent holding its own local affine transform; agents refine their transform against the image data and propagate what they find to their neighbours, and a forward/backward consistency check culls the ones that disagree. Repeating that coarse-to-fine yields a dense, geometrically consistent mapping.

Useful for optical flow, image registration and stitching, stereo matching, morphing, and as the front half of a 3D reconstruction.

PIXELMAP applied to two photos of a monkey statue

Install

pip install pixelmap-python

The package installs as pixelmap-python but imports as pixelmap — PyPI will not accept pixelmap as a distribution name, because it collides with the unrelated pixel-map project under PyPI's similarity rule.

Wheels are published for Linux (x86-64, aarch64, musl), macOS (Apple silicon and Intel) and Windows (x86-64), for CPython 3.9 and newer. NumPy is the only runtime dependency; no Rust toolchain is needed unless you build from source.

Quick start

import numpy as np
import pixelmap
from PIL import Image

a = np.asarray(Image.open("a.jpg").convert("RGB"))
b = np.asarray(Image.open("b.jpg").convert("RGB"))  # same dimensions as a

mapping = pixelmap.correspond(a, b, quality="low")

flow = mapping.flow()  # (H, W, 2) float32: how far each pixel moved
print(f"{mapping.coverage:.1%} of the image was mapped")

# Where did the pixel at (120, 84) end up?
print(mapping.lookup(120.0, 84.0))  # (114.2, 80.6), or None if unmapped

flow[y, x] is (dx, dy) in the source photos' own pixel coordinates. Regions the algorithm could not map — occlusions, featureless sky, anything the consistency check rejected — are NaN rather than a plausible-looking coordinate:

unmapped = np.isnan(flow[..., 0])

Coverage well below 1.0 is normal and not a failure. A very low value means the two photos had little in common, or are related by something an affine grid cannot express.

Warping one photo onto the other

flow(absolute=True) returns destination coordinates instead of displacements, which is what OpenCV's remap wants:

import cv2

dst = mapping.flow(absolute=True)
warped = cv2.remap(a, dst[..., 0], dst[..., 1], cv2.INTER_LINEAR)

There is also a built-in morph, which interpolates the first photo t of the way towards the second:

halfway = mapping.morph(0.5, detail=2)  # (h, w, 4) uint8, at working resolution

Watching a long run

mapping = pixelmap.correspond(
    a,
    b,
    quality=pixelmap.Quality.HIGH,
    progress=lambda step, total: print(f"{step}/{total}"),
)

The GIL is released while the solver runs, so correspond can be called from a worker thread without blocking the rest of your program.

To stop a run early, raise from the callback: the solver stops at the end of that step and your exception comes out of correspond. Ctrl-C stops it the same way, callback or not.

API

correspond(photo1, photo2, *, quality, seed, max_round_trip_error, fill_mode, progress) Run the pipeline.
Correspondence.flow(*, backward=False, absolute=False) The dense field as (H, W, 2) float32.
Correspondence.lookup(x, y, *, backward=False) One point, or NumPy arrays of them.
Correspondence.morph(t, *, detail=1) The first photo warped towards the second.
Correspondence.coverage Fraction of the image that got a mapping.
Correspondence.comparisons Region comparisons performed.
Correspondence.source_dimensions / .working_dimensions / .working_scale Geometry.
Correspondence.to_bytes() / .from_bytes(data, photo1, photo2) Save and reload a mapping.
Quality.LOW / .MEDIUM / .HIGH / .ULTRA Presets, or the equivalent strings.

Input. Photos are uint8 arrays of shape (H, W), (H, W, 1), (H, W, 3) or (H, W, 4) — Pillow images work directly. Both must have the same dimensions and be at least 32 pixels on each side. Violations raise SizeMismatchError, PhotoTooSmallError or ValueError, all of which are ValueError subclasses.

Quality. LOW, MEDIUM, HIGH and ULTRA run 4, 10, 13 and 15 refinement steps and finish at a working width of 400, 800, 1600 and 3200 pixels respectively, so cost grows faster than the step count suggests. Above LOW, no step works wider than your photos, so ULTRA is the same as HIGH on photos up to 1600 pixels wide. Those presets also fill the cells the final step left unmapped from earlier, coarser steps: more pixels get an answer, but the filled ones are less precise than the rest. flow and lookup answer in your photos' coordinates regardless; use working_scale if you need to reason about the solver's effective resolution.

Determinism. The same photos, quality and seed give the same mapping — run to run, thread to thread, and machine to machine. Pass seed= to vary it.

Building from source

Requires Rust 1.83 or newer.

git clone https://github.com/d4per/pixelmap-python
cd pixelmap-python
pip install maturin
maturin develop --release
pytest

maturin develop without --release builds an unoptimised solver that is many times slower; use it only for iterating on the bindings themselves.

See also

License

MIT — see LICENSE.

Metadata

Release files for pixelmap-python 0.4.0

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

Source distribution (sdist)

Source distribution for pixelmap-python 0.4.0
File Size Uploaded Provenance Actions
pixelmap_python-0.4.0.tar.gz 27.6 kB With provenance Details for pixelmap_python-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pixelmap-python 0.4.0
File Actions
pixelmap_python-0.4.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for pixelmap_python-0.4.0-cp39-abi3-win_amd64.whl
pixelmap_python-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for pixelmap_python-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl
pixelmap_python-0.4.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for pixelmap_python-0.4.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
pixelmap_python-0.4.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for pixelmap_python-0.4.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
pixelmap_python-0.4.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for pixelmap_python-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
pixelmap_python-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for pixelmap_python-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 2.5 MB

Release files / pixelmap_python-0.4.0.tar.gz

Download URL pixelmap_python-0.4.0.tar.gz
Size 27.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c735444506a8ff2ca3c8f996ff2ea8c64f740b8cda051219c6d3e1d4268c223c
BLAKE2b-256 checksum
How to use checksums
155ac6b9a262f89b711a8e09e5590b48ec9f63d5e1c4c027d9317062458fe310
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Release files / pixelmap_python-0.4.0-cp39-abi3-win_amd64.whl

Download URL pixelmap_python-0.4.0-cp39-abi3-win_amd64.whl
Size 283.1 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8c3f2c0b9dad0e21188dc5dfb2c24666c98938edf07cfb8e108f604fdd26c99c
BLAKE2b-256 checksum
How to use checksums
aaf533cad0bfe83ba8cf6f197ce95d07e711eb9463daccee69b1661321a4a994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Release files / pixelmap_python-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL pixelmap_python-0.4.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 613.3 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
3bf02892b0cb8ca30a8e2ebafeb2d4c4fd24262c2cb01b8ca394e0b45aaa712b
BLAKE2b-256 checksum
How to use checksums
890d26dbfce057a670e22cbf7393305f3a18493c948ed03c045b354b21d2abce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Release files / pixelmap_python-0.4.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pixelmap_python-0.4.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 403.4 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d3404916e79ce39c9528b54e6ec138e2f9f8936973f4091b7a272559aef27ff6
BLAKE2b-256 checksum
How to use checksums
eb19c6851ef6844d4eb1a26d9da788db32cad69003d3bd6aed1e0a1e81679f27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Release files / pixelmap_python-0.4.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL pixelmap_python-0.4.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 396.5 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
b3a757237e9c8812d6c3d695f9971afc2b0735aaddd10ea7b12ec2fa6c04b320
BLAKE2b-256 checksum
How to use checksums
5a9d7df310eb0c1d4b34beaf674ad85b21d8778ef5a9ba84b98e66f4d076cee7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Release files / pixelmap_python-0.4.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL pixelmap_python-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
Size 359.6 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
358553a9c6aa74446c9767ca031e4ff0610b421ac301376181660ee5df2c6a24
BLAKE2b-256 checksum
How to use checksums
0c3b097016256219561332c02abac5f4072eba9aa3492e7222562a440d6edae1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Release files / pixelmap_python-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL pixelmap_python-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 371.2 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d2d1a4da38dbd36cff74ada2c898307d69ae0e2e647634c0555719edd58f64c2
BLAKE2b-256 checksum
How to use checksums
b645c81c1cbfa59f63018ca857ca371993495c8167eca1e8e21d72707563aaaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Security for pixelmap-python 0.4.0

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 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for pixelmap_python-0.4.0.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 Nov 19, 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