daltoscope 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- daltoscope-0.1.0/LICENSE +21 -0
- daltoscope-0.1.0/PKG-INFO +72 -0
- daltoscope-0.1.0/README.md +48 -0
- daltoscope-0.1.0/daltoscope/__init__.py +69 -0
- daltoscope-0.1.0/daltoscope.egg-info/PKG-INFO +72 -0
- daltoscope-0.1.0/daltoscope.egg-info/SOURCES.txt +9 -0
- daltoscope-0.1.0/daltoscope.egg-info/dependency_links.txt +1 -0
- daltoscope-0.1.0/daltoscope.egg-info/requires.txt +5 -0
- daltoscope-0.1.0/daltoscope.egg-info/top_level.txt +1 -0
- daltoscope-0.1.0/pyproject.toml +35 -0
- daltoscope-0.1.0/setup.cfg +4 -0
daltoscope-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vince Gonzalez (OpticQuiz)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: daltoscope
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: See a color, a palette, or a whole image as a colorblind person does — recolors for protanopia, deuteranopia, and tritanopia (Machado, Oliveira & Fernandes 2009).
|
|
5
|
+
Author: Vince Gonzalez
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://opticquiz.com/
|
|
8
|
+
Project-URL: Source, https://github.com/vince-gonzalez/opticquiz.com
|
|
9
|
+
Keywords: colorblind,color-blindness,daltonism,cvd,color-vision-deficiency,simulate,protanopia,deuteranopia,tritanopia,accessibility,a11y,image
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: opticquiz-cvd>=1.1.0
|
|
20
|
+
Provides-Extra: image
|
|
21
|
+
Requires-Dist: pillow>=9.0; extra == "image"
|
|
22
|
+
Requires-Dist: numpy>=1.21; extra == "image"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# daltoscope
|
|
26
|
+
|
|
27
|
+
**See a color, a palette, or a whole image the way a colorblind person does.** Where `hueristic`
|
|
28
|
+
*judges* whether colors are safe, `daltoscope` *shows* you — it recolors a hex, or an entire
|
|
29
|
+
PNG/JPEG, as protanopia, deuteranopia, or tritanopia renders it.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install daltoscope # colors only
|
|
33
|
+
pip install "daltoscope[image]" # + image recoloring (Pillow, numpy)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import daltoscope as dalton
|
|
38
|
+
|
|
39
|
+
dalton.simulate("#d7191c", "deutan") # "#8a7b0c" — that warning red, to a deuteranope
|
|
40
|
+
dalton.simulate_all("#1a9641") # {"protan": "#988839", "deutan": "#8a7f48", "tritan": "#009383"}
|
|
41
|
+
|
|
42
|
+
from PIL import Image
|
|
43
|
+
sim = dalton.simulate_image(Image.open("dashboard.png"), "deutan")
|
|
44
|
+
sim.save("dashboard-deutan.png")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
- **`simulate(color, type, severity=1.0)`** → the color as one deficiency sees it, as hex.
|
|
50
|
+
`type` is `"protan"`, `"deutan"`, or `"tritan"`.
|
|
51
|
+
- **`simulate_all(color, severity=1.0)`** → `{"protan": ..., "deutan": ..., "tritan": ...}`.
|
|
52
|
+
- **`simulate_image(image, type, severity=1.0)`** → a recolored PIL `Image` (alpha preserved).
|
|
53
|
+
`image` is a PIL `Image` or a file path. `severity` (0..1) shows partial deficiency
|
|
54
|
+
(anomalous trichromacy), not only the full dichromat case.
|
|
55
|
+
|
|
56
|
+
## How it works
|
|
57
|
+
|
|
58
|
+
`daltoscope` is a thin lens over [`opticquiz-cvd`](https://pypi.org/project/opticquiz-cvd/): every
|
|
59
|
+
pixel's transform is that engine's `simulate()`, using the Machado, Oliveira & Fernandes (2009)
|
|
60
|
+
deficiency matrices. `simulate_image` passes each *distinct* color through the engine once via a
|
|
61
|
+
lookup table, so a photograph is not thousands of redundant calls — and there is never a second
|
|
62
|
+
copy of the colorimetry to drift. Method, open access:
|
|
63
|
+
https://doi.org/10.5281/zenodo.21310578
|
|
64
|
+
|
|
65
|
+
## Not a clinical tool
|
|
66
|
+
|
|
67
|
+
A simulation for design and communication — it approximates how deficient color vision renders an
|
|
68
|
+
image. It is not a diagnosis, and no on-screen rendering is exact for a given individual.
|
|
69
|
+
|
|
70
|
+
## Licence
|
|
71
|
+
|
|
72
|
+
MIT.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# daltoscope
|
|
2
|
+
|
|
3
|
+
**See a color, a palette, or a whole image the way a colorblind person does.** Where `hueristic`
|
|
4
|
+
*judges* whether colors are safe, `daltoscope` *shows* you — it recolors a hex, or an entire
|
|
5
|
+
PNG/JPEG, as protanopia, deuteranopia, or tritanopia renders it.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install daltoscope # colors only
|
|
9
|
+
pip install "daltoscope[image]" # + image recoloring (Pillow, numpy)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
import daltoscope as dalton
|
|
14
|
+
|
|
15
|
+
dalton.simulate("#d7191c", "deutan") # "#8a7b0c" — that warning red, to a deuteranope
|
|
16
|
+
dalton.simulate_all("#1a9641") # {"protan": "#988839", "deutan": "#8a7f48", "tritan": "#009383"}
|
|
17
|
+
|
|
18
|
+
from PIL import Image
|
|
19
|
+
sim = dalton.simulate_image(Image.open("dashboard.png"), "deutan")
|
|
20
|
+
sim.save("dashboard-deutan.png")
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API
|
|
24
|
+
|
|
25
|
+
- **`simulate(color, type, severity=1.0)`** → the color as one deficiency sees it, as hex.
|
|
26
|
+
`type` is `"protan"`, `"deutan"`, or `"tritan"`.
|
|
27
|
+
- **`simulate_all(color, severity=1.0)`** → `{"protan": ..., "deutan": ..., "tritan": ...}`.
|
|
28
|
+
- **`simulate_image(image, type, severity=1.0)`** → a recolored PIL `Image` (alpha preserved).
|
|
29
|
+
`image` is a PIL `Image` or a file path. `severity` (0..1) shows partial deficiency
|
|
30
|
+
(anomalous trichromacy), not only the full dichromat case.
|
|
31
|
+
|
|
32
|
+
## How it works
|
|
33
|
+
|
|
34
|
+
`daltoscope` is a thin lens over [`opticquiz-cvd`](https://pypi.org/project/opticquiz-cvd/): every
|
|
35
|
+
pixel's transform is that engine's `simulate()`, using the Machado, Oliveira & Fernandes (2009)
|
|
36
|
+
deficiency matrices. `simulate_image` passes each *distinct* color through the engine once via a
|
|
37
|
+
lookup table, so a photograph is not thousands of redundant calls — and there is never a second
|
|
38
|
+
copy of the colorimetry to drift. Method, open access:
|
|
39
|
+
https://doi.org/10.5281/zenodo.21310578
|
|
40
|
+
|
|
41
|
+
## Not a clinical tool
|
|
42
|
+
|
|
43
|
+
A simulation for design and communication — it approximates how deficient color vision renders an
|
|
44
|
+
image. It is not a diagnosis, and no on-screen rendering is exact for a given individual.
|
|
45
|
+
|
|
46
|
+
## Licence
|
|
47
|
+
|
|
48
|
+
MIT.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""daltoscope — see a color, a palette, or a whole image as a colorblind person does.
|
|
2
|
+
|
|
3
|
+
Named for daltonism (color blindness, after John Dalton). Where ``hueristic`` judges whether
|
|
4
|
+
colors are safe, ``daltoscope`` shows what they look like through a color-vision deficiency —
|
|
5
|
+
a single color, or an entire image recolored.
|
|
6
|
+
|
|
7
|
+
import daltoscope as dalton
|
|
8
|
+
|
|
9
|
+
dalton.simulate("#d7191c", "deutan") # "#8a7b0c" — that red, to a deuteranope
|
|
10
|
+
dalton.simulate_all("#1a9641") # {"protan": "#988839", "deutan": "#8a7f48", "tritan": "#009383"}
|
|
11
|
+
|
|
12
|
+
from PIL import Image
|
|
13
|
+
sim = dalton.simulate_image(Image.open("chart.png"), "deutan")
|
|
14
|
+
sim.save("chart-deutan.png")
|
|
15
|
+
|
|
16
|
+
The per-color transform is ``opticquiz_cvd.simulate`` (Machado, Oliveira & Fernandes 2009);
|
|
17
|
+
nothing about the simulation is reimplemented here.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from opticquiz_cvd import simulate, TYPES
|
|
21
|
+
|
|
22
|
+
__version__ = "0.1.0"
|
|
23
|
+
__all__ = ["simulate", "simulate_all", "simulate_image", "TYPES"]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def simulate_all(color, severity=1.0):
|
|
27
|
+
"""The same color under all three deficiencies, for side-by-side comparison."""
|
|
28
|
+
return {t: simulate(color, t, severity) for t in TYPES}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _hex_to_rgb(h):
|
|
32
|
+
n = int(str(h).lstrip("#"), 16)
|
|
33
|
+
return ((n >> 16) & 255, (n >> 8) & 255, n & 255)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def simulate_image(image, type, severity=1.0):
|
|
37
|
+
"""Recolor an image as ``type`` (protan | deutan | tritan) sees it.
|
|
38
|
+
|
|
39
|
+
``image`` is a PIL ``Image`` or a file path. Returns a PIL ``Image`` (RGB or RGBA to match
|
|
40
|
+
the input). Every distinct color is passed through the engine once via a lookup table, so a
|
|
41
|
+
photograph is not thousands of redundant calls.
|
|
42
|
+
"""
|
|
43
|
+
if type not in TYPES:
|
|
44
|
+
raise ValueError('type must be one of "protan", "deutan", "tritan".')
|
|
45
|
+
try:
|
|
46
|
+
import numpy as np
|
|
47
|
+
from PIL import Image
|
|
48
|
+
except ImportError as e: # pragma: no cover
|
|
49
|
+
raise ImportError(
|
|
50
|
+
"simulate_image needs Pillow and numpy — `pip install daltoscope[image]`."
|
|
51
|
+
) from e
|
|
52
|
+
|
|
53
|
+
if isinstance(image, str):
|
|
54
|
+
image = Image.open(image)
|
|
55
|
+
has_alpha = image.mode in ("RGBA", "LA", "PA") or "transparency" in image.info
|
|
56
|
+
rgb = np.asarray(image.convert("RGB"), dtype=np.uint8)
|
|
57
|
+
alpha = np.asarray(image.convert("RGBA"), dtype=np.uint8)[..., 3] if has_alpha else None
|
|
58
|
+
|
|
59
|
+
flat = rgb.reshape(-1, 3)
|
|
60
|
+
uniq, inverse = np.unique(flat, axis=0, return_inverse=True)
|
|
61
|
+
mapped = np.empty_like(uniq)
|
|
62
|
+
for i, (r, g, b) in enumerate(uniq):
|
|
63
|
+
mapped[i] = _hex_to_rgb(simulate("#%02x%02x%02x" % (r, g, b), type, severity))
|
|
64
|
+
out = mapped[inverse].reshape(rgb.shape).astype(np.uint8)
|
|
65
|
+
|
|
66
|
+
if alpha is not None:
|
|
67
|
+
out = np.dstack([out, alpha])
|
|
68
|
+
return Image.fromarray(out, "RGBA")
|
|
69
|
+
return Image.fromarray(out, "RGB")
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: daltoscope
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: See a color, a palette, or a whole image as a colorblind person does — recolors for protanopia, deuteranopia, and tritanopia (Machado, Oliveira & Fernandes 2009).
|
|
5
|
+
Author: Vince Gonzalez
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://opticquiz.com/
|
|
8
|
+
Project-URL: Source, https://github.com/vince-gonzalez/opticquiz.com
|
|
9
|
+
Keywords: colorblind,color-blindness,daltonism,cvd,color-vision-deficiency,simulate,protanopia,deuteranopia,tritanopia,accessibility,a11y,image
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: opticquiz-cvd>=1.1.0
|
|
20
|
+
Provides-Extra: image
|
|
21
|
+
Requires-Dist: pillow>=9.0; extra == "image"
|
|
22
|
+
Requires-Dist: numpy>=1.21; extra == "image"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# daltoscope
|
|
26
|
+
|
|
27
|
+
**See a color, a palette, or a whole image the way a colorblind person does.** Where `hueristic`
|
|
28
|
+
*judges* whether colors are safe, `daltoscope` *shows* you — it recolors a hex, or an entire
|
|
29
|
+
PNG/JPEG, as protanopia, deuteranopia, or tritanopia renders it.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install daltoscope # colors only
|
|
33
|
+
pip install "daltoscope[image]" # + image recoloring (Pillow, numpy)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import daltoscope as dalton
|
|
38
|
+
|
|
39
|
+
dalton.simulate("#d7191c", "deutan") # "#8a7b0c" — that warning red, to a deuteranope
|
|
40
|
+
dalton.simulate_all("#1a9641") # {"protan": "#988839", "deutan": "#8a7f48", "tritan": "#009383"}
|
|
41
|
+
|
|
42
|
+
from PIL import Image
|
|
43
|
+
sim = dalton.simulate_image(Image.open("dashboard.png"), "deutan")
|
|
44
|
+
sim.save("dashboard-deutan.png")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
- **`simulate(color, type, severity=1.0)`** → the color as one deficiency sees it, as hex.
|
|
50
|
+
`type` is `"protan"`, `"deutan"`, or `"tritan"`.
|
|
51
|
+
- **`simulate_all(color, severity=1.0)`** → `{"protan": ..., "deutan": ..., "tritan": ...}`.
|
|
52
|
+
- **`simulate_image(image, type, severity=1.0)`** → a recolored PIL `Image` (alpha preserved).
|
|
53
|
+
`image` is a PIL `Image` or a file path. `severity` (0..1) shows partial deficiency
|
|
54
|
+
(anomalous trichromacy), not only the full dichromat case.
|
|
55
|
+
|
|
56
|
+
## How it works
|
|
57
|
+
|
|
58
|
+
`daltoscope` is a thin lens over [`opticquiz-cvd`](https://pypi.org/project/opticquiz-cvd/): every
|
|
59
|
+
pixel's transform is that engine's `simulate()`, using the Machado, Oliveira & Fernandes (2009)
|
|
60
|
+
deficiency matrices. `simulate_image` passes each *distinct* color through the engine once via a
|
|
61
|
+
lookup table, so a photograph is not thousands of redundant calls — and there is never a second
|
|
62
|
+
copy of the colorimetry to drift. Method, open access:
|
|
63
|
+
https://doi.org/10.5281/zenodo.21310578
|
|
64
|
+
|
|
65
|
+
## Not a clinical tool
|
|
66
|
+
|
|
67
|
+
A simulation for design and communication — it approximates how deficient color vision renders an
|
|
68
|
+
image. It is not a diagnosis, and no on-screen rendering is exact for a given individual.
|
|
69
|
+
|
|
70
|
+
## Licence
|
|
71
|
+
|
|
72
|
+
MIT.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
daltoscope
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "daltoscope"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "See a color, a palette, or a whole image as a colorblind person does — recolors for protanopia, deuteranopia, and tritanopia (Machado, Oliveira & Fernandes 2009)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Vince Gonzalez" }]
|
|
13
|
+
keywords = [
|
|
14
|
+
"colorblind", "color-blindness", "daltonism", "cvd", "color-vision-deficiency",
|
|
15
|
+
"simulate", "protanopia", "deuteranopia", "tritanopia", "accessibility", "a11y", "image",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 4 - Beta",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Topic :: Multimedia :: Graphics",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
24
|
+
]
|
|
25
|
+
dependencies = ["opticquiz-cvd>=1.1.0"]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
image = ["pillow>=9.0", "numpy>=1.21"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://opticquiz.com/"
|
|
32
|
+
Source = "https://github.com/vince-gonzalez/opticquiz.com"
|
|
33
|
+
|
|
34
|
+
[tool.setuptools]
|
|
35
|
+
packages = ["daltoscope"]
|