Skip to main content

DaltonLens-Python

Unit Tests

This python package is a companion to the desktop application DaltonLens. Its main goal is to help the research and development of better color filters for people with color vision deficiencies. It also powers the Jupyter notebooks used for the technical posts of daltonlens.org. The current features include:

  • Simulate color vision deficiencies using the Viénot 1999, Brettel 1997 or Machado 2009 models.
  • Provide conversion functions to/from sRGB, linear RGB and LMS
  • Implement several variants of the LMS model
  • Generate Ishihara-like test images

For a discussion about which CVD simulation algorithms are the most accurate see our Review of Open Source Color Blindness Simulations.

For more information about the math of the chosen algorithms see our article Understanding CVD Simulation.

Install

python3 -m pip install daltonlens

How to use

From the command line

daltonlens-python --help
usage: daltonlens-python [-h] 
       [--model MODEL] [--filter FILTER]
       [--deficiency DEFICIENCY] [--severity SEVERITY]
       input_image output_image

Toolbox to simulate and filter color vision deficiencies.

positional arguments:
  input_image           Image to process.
  output_image          Output image

optional arguments:
  -h, --help            show this help message and exit
  --model MODEL, -m MODEL
                        Color model to apply: vienot, brettel, machado or auto (default: auto)
  --filter FILTER, -f FILTER
                        Filter to apply: simulate or daltonize. (default: simulate)
  --deficiency DEFICIENCY, -d DEFICIENCY
                        Deficiency type: protan, deutan or tritan (default: protan)
  --severity SEVERITY, -s SEVERITY
                        Severity between 0 and 1 (default: 1.0)

From code

from daltonlens import convert, simulate, generate
import PIL
import numpy as np

# Generate a test image that spans the RGB range
im = np.asarray(PIL.Image.open("test.png").convert('RGB'))

# Create a simulator using the Viénot 1999 algorithm.
simulator = simulate.Simulator_Vienot1999()

# Apply the simulator to the input image to get a simulation of protanomaly
protan_im = simulator.simulate_cvd (im, simulate.Deficiency.PROTAN, severity=0.8)

Metadata

Release files for daltonlens 0.1.5

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

Source distribution (sdist)

Source distribution for daltonlens 0.1.5
File Size Uploaded
daltonlens-0.1.5.tar.gz 293.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for daltonlens 0.1.5
File Interpreter ABI Platform
daltonlens-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 339.8 kB

Release files / daltonlens-0.1.5.tar.gz

Download URL daltonlens-0.1.5.tar.gz
Size 293.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4fb7d7951745b5c570e565113ea6610a6ba5522d599c27c25e070bb531de35ab
BLAKE2b-256 checksum
How to use checksums
c5b3beff9de96a0b68746507bc8a10ffb541e691c063b9a8675daaf4088a8c1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Release files / daltonlens-0.1.5-py3-none-any.whl

Download URL daltonlens-0.1.5-py3-none-any.whl
Size 46.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e66edeb4bb006579a60a9ed221a23a9493349b633cdf1c18133805f36d8ccd5f
BLAKE2b-256 checksum
How to use checksums
65e7a6bea606f4e57fbfbbd5334e715be25c1d97d9018ff184ba5ec6e66c3b34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

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