Bijective metric-depth <-> RGB colormap along a 3D Hilbert cube walk, as used in the Vision Banana paper.
Project description
🎨 3D Hilbert Depth Colormap
Give your depth estimation a fancy new colormap! Here you'll find an implementation of a bijective metric-depth <-> RGB mapping along a 3D Hilbert cube walk, as used in the Vision Banana 🍌 paper [1].
📦 Installation
From PyPI:
pip install hilbertmap
From source:
git clone https://github.com/massimilianoviola/hilbertmap
cd hilbertmap
pip install -e .
🛠️ Usage
Direct encoding/decoding
import numpy as np
from hilbertmap import depth_to_rgb, rgb_to_depth
depth = np.load("depth.npy") # (H, W) float meters
rgb = depth_to_rgb(depth) # (H, W, 3) float in [0, 1]
back = rgb_to_depth(rgb) # (H, W) recovered meters
Visualization with matplotlib
import matplotlib.pyplot as plt
import hilbertmap as hm
im = plt.imshow(depth, cmap=hm.cmap(), norm=hm.Norm())
hm.colorbar(im, label="depth (m)")
plt.show()
hm.Norm applies the fixed power transform; hm.colorbar paints only the cmap subset the data actually covers.
🧭 How it works
The seven-edge Hamiltonian path on the RGB cube (left) carries depth values from black at zero to white at infinity. The shape parameters $\lambda$ and $c$ produce different saturation curves (right) that decide how much depth lives on each segment of the walk.
| Cube walk | Saturation curves |
Unbounded metric depth $d \in [0, \infty)$ is squashed into $[0, 1)$ by a power transform from Barron (2025) [2]:
$$f(d, \lambda, c) = 1 - \left(1 - \frac{d}{\lambda c}\right)^{\lambda + 1}$$
With defaults $\lambda = -3$, $c = 10/3$ this simplifies to $f(d) = 1 - (1 + d/10)^{-2}$, mapping $d \in [0, \infty)$ to $f \in [0, 1)$, which is then read as the fractional position along the edge walk to land on $\mathrm{RGB} \in [0, 1]^3$. The mapping is a strict bijection, so any RGB encoding can be decoded back to metric depth by projecting onto the nearest edge.
Because the utility of accurate metric depth for nearby image content is generally higher than that of distant content, the default parameters $\lambda = -3$, $c = 10/3$ make the cube walk most sensitive in the first few meters and saturate beyond ~35 m. This behavior can be tuned by changing the parameters to get more meaningful color variation on deep outdoor scenes.
📚 References
- V. Gabeur et al. Vision Banana: Image generators are generalist vision learners. arXiv preprint arXiv:2604.20329, 2026. Project page: https://vision-banana.github.io/.
- J. T. Barron. A power transform. arXiv preprint arXiv:2502.10647, 2025.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hilbertmap-0.1.1.tar.gz.
File metadata
- Download URL: hilbertmap-0.1.1.tar.gz
- Upload date:
- Size: 3.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
017665cfb3f25ec86bfead17e71087083f7ae02db933840225da971d30ede60d
|
|
| MD5 |
38003a0926ea3aeaa36873886f329069
|
|
| BLAKE2b-256 |
6fc9b00f45261eddd2847bc1c8377883ad62923ed80404f738509a649decfd17
|
Provenance
The following attestation bundles were made for hilbertmap-0.1.1.tar.gz:
Publisher:
publish.yml on massimilianoviola/hilbertmap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hilbertmap-0.1.1.tar.gz -
Subject digest:
017665cfb3f25ec86bfead17e71087083f7ae02db933840225da971d30ede60d - Sigstore transparency entry: 1382753920
- Sigstore integration time:
-
Permalink:
massimilianoviola/hilbertmap@877687b08415da994fc4f2690526cb94d5d1b748 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/massimilianoviola
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@877687b08415da994fc4f2690526cb94d5d1b748 -
Trigger Event:
release
-
Statement type:
File details
Details for the file hilbertmap-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hilbertmap-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a63d8d0d9192b0ad2c1682133f34907547bd52afecbfc022c5b5fcd9860f094
|
|
| MD5 |
8e912cc7ee0a24490b9459dbf66a78e8
|
|
| BLAKE2b-256 |
cecdcdb1362ea510a4d57aa1bbba0f9ec05e395a43e51c65dbc8b7f921697b2d
|
Provenance
The following attestation bundles were made for hilbertmap-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on massimilianoviola/hilbertmap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hilbertmap-0.1.1-py3-none-any.whl -
Subject digest:
7a63d8d0d9192b0ad2c1682133f34907547bd52afecbfc022c5b5fcd9860f094 - Sigstore transparency entry: 1382753938
- Sigstore integration time:
-
Permalink:
massimilianoviola/hilbertmap@877687b08415da994fc4f2690526cb94d5d1b748 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/massimilianoviola
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@877687b08415da994fc4f2690526cb94d5d1b748 -
Trigger Event:
release
-
Statement type: