Skip to content

Commit

Permalink
Fixed tritanopia simulation (#525)
Browse files Browse the repository at this point in the history
Fixed a typo causing incorrect simulation of tritanopic color vision deficiencies. Also added tests for this corrected behavior
  • Loading branch information
williamjsdavis authored Dec 13, 2022
1 parent eefe438 commit dc6438f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function tritanopic(q::T, p, neutral::LMS) where T <: Color

q = LMS(q.l,
q.m,
(one(p) - p) * q.l + p * (-(a*q.l + b*q.m)/c))
(one(p) - p) * q.s + p * (-(a*q.l + b*q.m)/c))
convert(T, q)
end

Expand Down
6 changes: 6 additions & 0 deletions test/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ using Test, Colors
# yellow in LCHab
@test Colors.find_maximum_chroma(LCHab(94.2, 0, 100)) 93.749 atol=0.01
@test Colors.find_maximum_chroma(LCHab(97.6, 0, 105)) 68.828 atol=0.01

# Color vision deficiency simulations at p=0
rgb = RGB(0.44, 0.26, 0.8)
@test protanopic(rgb, 0) .≈ rgb
@test deuteranopic(rgb, 0) .≈ rgb
@test tritanopic(rgb, 0) .≈ rgb
end

0 comments on commit dc6438f

Please sign in to comment.