Code Monkey home page Code Monkey logo

daltonlens-python's Introduction

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)

daltonlens-python's People

Contributors

nburrus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

daltonlens-python's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.