ByakuganVisualizer is a Python tool for comparing images, highlighting visual differences, and applying color filters.
I have a mix of deuteranomaly and protanomaly, which motivated me to create this repository! Now I can solve every colorblind test.
- Compare two images and generate a difference image
- Apply red, green, blue, or yellow channel filters
- Apply deuteranomaly and protanomaly correction
- Process one or multiple images from the command line
- Use the functionality directly from Python
The deuteranomaly and protanomaly values control the strength of the correction.
Example:
byakugan_vision --images "tests/test_images/naruto.jpg" --deuteranomaly 2 --protanomaly 2The algorithm is based on the following paper:
https://arxiv.org/abs/1711.10662
Correction in this context means that the image colors are adjusted to make differences more distinguishable for people with color vision deficiencies.
byakugan_vision --images "tests/test_images/color_blind_test.jpg" --deuteranomaly 2byakugan_vision --images "tests/test_images/color_blind_test.jpg" --protanomaly 2byakugan_vision --images "tests/test_images/color_blind_test.jpg" --deuteranomaly 2 --protanomaly 2byakugan_vision --images "tests/test_images/color_blind_test.jpg" --deuteranomaly 0.5 --protanomaly 0.5pip install byakuganvisualizerFor local development:
git clone https://github.com/HokageM/ByakuganVisualizer.git
cd ByakuganVisualizer
pip install -e .byakugan_vision --helpusage: byakugan_vision [-h] [--version]
(--diff DIFF | --images IMAGES)
[--filter {red,blue,green,yellow}]
[--deuteranomaly DEUTERANOMALY]
[--protanomaly PROTANOMALY]
[--out_dir OUT_DIR]
ByakuganVisualizer: Tool for correcting the color palette for color-blind users
and highlighting differences between images.
options:
-h, --help show this help message and exit
--version show program's version number and exit
processing mode:
--diff DIFF Image pairs to compare.
Format:
"Path_To_Image1a,Path_To_Image2a;Path_To_Image1b,Path_To_Image2b"
--images IMAGES Comma-separated list of image paths to process.
Example:
"image_a.jpg,image_b.jpg,image_c.jpg"
filter options:
--filter {red,blue,green,yellow}
Filter type to apply.
--deuteranomaly DEUTERANOMALY
Degree of deuteranomaly correction. Default is 0.
--protanomaly PROTANOMALY
Degree of protanomaly correction. Default is 0.
output options:
--out_dir OUT_DIR Output directory for generated images. Default is current directory.
--diff and --images are mutually exclusive. Use one or the other.
byakugan_vision --images "tests/test_images/naruto.jpg" --filter redOutput:
Filtered_naruto_red.jpg
byakugan_vision --images "tests/test_images/naruto.jpg,tests/test_images/naruto_modified.jpg" --filter bluebyakugan_vision --images "tests/test_images/naruto.jpg" --deuteranomaly 2byakugan_vision --images "tests/test_images/naruto.jpg" --protanomaly 2byakugan_vision --images "tests/test_images/naruto.jpg" --deuteranomaly 2 --protanomaly 2byakugan_vision --images "tests/test_images/naruto.jpg" --deuteranomaly 0.5 --protanomaly 0.5The left image used in this example is from the following source:
https://www.anime2you.de/news/606180/naruto-feiert-20-anime-jubilaeum/
byakugan_vision --diff "tests/test_images/naruto.jpg,tests/test_images/naruto_modified.jpg" --out_dir tests/test_images/diffOutput:
Diff_naruto_naruto_modified.jpg
byakugan_vision --diff "tests/test_images/naruto.jpg,tests/test_images/naruto_modified.jpg" --filter red --out_dir tests/test_images/diffOutput:
Diff_naruto_naruto_modified_red.jpg
The refactored API uses ByakuganProcessor as the main processing class:
from byakuganvisualizer.processor import ByakuganProcessor
processor = ByakuganProcessor(
out_dir="tests/test_images/filtered",
filter_name="red",
)
processor.process_image("tests/test_images/naruto.jpg")from byakuganvisualizer.processor import ByakuganProcessor
processor = ByakuganProcessor(
out_dir="tests/test_images/filtered",
filter_name="blue",
)
processor.process_images(
[
"tests/test_images/naruto.jpg",
"tests/test_images/naruto_modified.jpg",
]
)from byakuganvisualizer.processor import ByakuganProcessor
processor = ByakuganProcessor(out_dir="tests/test_images/diff")
processor.calculate_diff(
"tests/test_images/naruto.jpg",
"tests/test_images/naruto_modified.jpg",
)from byakuganvisualizer.processor import ByakuganProcessor
processor = ByakuganProcessor(out_dir="tests/test_images/diff")
processor.calculate_diffs(
[
(
"tests/test_images/naruto.jpg",
"tests/test_images/naruto_modified.jpg",
),
]
)The Byakugan from Naruto is a powerful ability that allows users to see through objects, detect chakra, and perceive long distances.
This project uses the name as a metaphor for making visual differences easier to see.
This project is licensed under the MIT License. See the LICENSE file for details.












