smallblind
smallblind is a Python library for simulating color vision deficiency (CVD) on images, matplotlib/seaborn plots, and raw color palettes.
Installation
pip install git+https://github.com/chriso345/smallblind.git
Usage
import smallblind as sb
# Simulate a CVD type on an image (path, PIL.Image, or numpy array all work)
result = sb.simulate("chart.png", "deuteranopia")
result.save("chart_deuteranopia.png")
# Simulate on a matplotlib/seaborn palette
import seaborn as sns
palette = sns.color_palette("Set1")
safe_view = sb.simulate_palette(palette, sb.CVDType.PROTANOPIA)
# Check whether the palette holds up under common CVD types
report = sb.check_palette_safety(palette)
if not report.is_safe:
for warning in report.warnings:
print(warning)
Matplotlib Figures
sb.simulate_figure rasterizes a Figure and returns a new PIL.Image, leaving the original figure untouched. This works for anything matplotlib can draw, including seaborn plots.
import matplotlib.pyplot as plt
import smallblind as sb
fig, ax = plt.subplots()
ax.plot([0, 1, 2], [0, 1, 0], color="red")
ax.plot([0, 1, 2], [1, 0, 1], color="green")
sb.simulate_figure(fig, "deuteranopia").save("figure_deuteranopia.png")
Comparison Grids
sb.compare builds a single labeled grid comparing the original against one or more CVD types.
grid = sb.compare("chart.png", cvd="all", columns=3)
grid.save("chart_comparison.png")
Palette Safety Checking
sb.check_palette_safety flags palette colors that become hard to tell apart under CVD, returning a SafetyReport with is_safe, warnings, and the underlying confusions list.
report = sb.check_palette_safety(
[(0.85, 0.10, 0.10), (0.10, 0.75, 0.10), (0.10, 0.40, 0.90)],
cvd_types=["protanopia", "deuteranopia"],
)
report.is_safe # False
report.warnings # ["colors 0 and 1 are hard to distinguish under deuteranopia (distance=..)"]
Jupyter Notebooks
Every image-producing function in smallblind (sb.simulate, sb.simulate_image, sb.simulate_figure, sb.compare) returns a plain PIL.Image, which Jupyter renders inline automatically.
import smallblind as sb
sb.compare("chart.png", cvd="common") # renders inline, no extra imports needed
License
Licensed under the MIT License. See the LICENSE file for more details.
Metadata
Release files for smallblind 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| smallblind-0.1.0.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| smallblind-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.6 kB
Release files / smallblind-0.1.0.tar.gz
| Download URL | smallblind-0.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80273972b82e43a093060b183452ce821547b20ff312d65265a0af299894a601
|
|
BLAKE2b-256 checksum How to use checksums |
af62c81b8c139556a22384fd052e3091a1b09a2bc0ea70538d4a5ebf7c73068e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / smallblind-0.1.0-py3-none-any.whl
| Download URL | smallblind-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
76bf3d8fb141189b0e18c270de8803f9d8e44d63529583be16fde7f5c05ec063
|
|
BLAKE2b-256 checksum How to use checksums |
d4a53f88dff587e69868e6982e68fb669c9d66eb71b691b3096ea6e419f86c1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|