Package colorblind
Class ColorUtilities
java.lang.Object
colorblind.ColorUtilities
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
applyGammaCorrection
(float s, float gamma) Apply Gamma Correctionstatic float
applyGammaCorrectionStandardRGB
(float s) Apply Standard Gamma Correctionstatic float
clip
(float x) Simple utility function that is used in a couple of places.static float
clip
(float x, float min, float max) Simple utility function that is used in a couple of places.static int
confusingDeuteranopiaColor
(int color, float x) static int
confusingDichromaticColor
(Deficiency colorBlindness, int color, float x) Intentionally generate colors that would be confusing to a colorblind person.static int
confusingMonochromaticColor
(Deficiency colorBlindness, int color, float x1, float x2) Intentionally generate colors that would be confusing to someone with monochromatic vision.static int
confusingProtanopiaColor
(int color, float x) static int
confusingTritanopiaColor
(int color, float x) static Vector
convertLinearRGB2LMS
(Vector rgbColor) static int
convertLinearRGB2PColor
(Vector rgbColor) static Vector
convertLMS2LinearRGB
(Vector lmsColor) static int
convertLMS2PColor
(Vector lmsColor) static Vector
convertPColor2LinearRGB
(int color) static Vector
convertPColor2LMS
(int color) static float
lmsFeasibleBisectionSearch
(Vector lms, int index, int direction) Search the LMS color space for the feasibility edge.static float
removeGammaCorrection
(float s, float gamma) Remove Gamma Correctionstatic float
removeGammaCorrectionStandardRGB
(float s) Remove Standard Gamma Correction
-
Field Details
-
protanopiaSim
-
deuteranopiaSim
-
tritanopiaSim
-
achromatopsiaSim
-
blueConeMonochromacySim
-
customSim
-
shiftTowardsVisible
-
rgb2lms
-
lms2rgb
-
-
Constructor Details
-
ColorUtilities
public ColorUtilities()
-
-
Method Details
-
clip
public static float clip(float x) Simple utility function that is used in a couple of places.- Parameters:
x
-- Returns:
- x constrained to [0, 1]
-
clip
public static float clip(float x, float min, float max) Simple utility function that is used in a couple of places.- Parameters:
x
-min
-max
-- Returns:
- x constrained to [min, max]
-
applyGammaCorrection
public static float applyGammaCorrection(float s, float gamma) Apply Gamma Correction- Parameters:
s
- = value [0, 1]- Returns:
-
removeGammaCorrection
public static float removeGammaCorrection(float s, float gamma) Remove Gamma Correction- Parameters:
s
- = value [0, 1]- Returns:
-
applyGammaCorrectionStandardRGB
public static float applyGammaCorrectionStandardRGB(float s) Apply Standard Gamma Correction- Parameters:
s
- = value [0, 1]- Returns:
-
removeGammaCorrectionStandardRGB
public static float removeGammaCorrectionStandardRGB(float s) Remove Standard Gamma Correction- Parameters:
s
- = value [0, 1]- Returns:
-
convertLinearRGB2LMS
-
convertLMS2LinearRGB
-
convertPColor2LinearRGB
-
convertPColor2LMS
-
convertLinearRGB2PColor
-
convertLMS2PColor
-
confusingDichromaticColor
Intentionally generate colors that would be confusing to a colorblind person. If a plot of all possible colors were a 3D space, there would be lines of colors in the 3D space that would look identical to a colorblind person. This code attempts to pick multiple colors along those lines.- Parameters:
colorBlindness
- color deficiencycolor
- initial colorx
- float [0, 1]- Returns:
- new color that is determined by x
-
confusingProtanopiaColor
public static int confusingProtanopiaColor(int color, float x) -
confusingDeuteranopiaColor
public static int confusingDeuteranopiaColor(int color, float x) -
confusingTritanopiaColor
public static int confusingTritanopiaColor(int color, float x) -
lmsFeasibleBisectionSearch
Search the LMS color space for the feasibility edge. If I convert a Processing color to LMS color space, how far can I adjust one of the 3 values until it can no longer be converted back to a valid Processing color? This function answers that question. Using a bisection search, find the min or max value of one value in the lms vector that is on the edge of the range that converts back to a feasible vector in linear RGB space.- Parameters:
lms
- Vector of color in LMS spaceindex
- index into lms vector to changedirection
- 1 or -1 to search in bigger or smaller direction- Returns:
- feasible value on edge of feasibility
-
confusingMonochromaticColor
public static int confusingMonochromaticColor(Deficiency colorBlindness, int color, float x1, float x2) Intentionally generate colors that would be confusing to someone with monochromatic vision. If a plot of all possible colors were a 3D space, there would be planes of colors in the 3D space that would look identical to a monochromat person. This code attempts to pick multiple colors on those planes.- Parameters:
color
- initial colorx1
- float [0, 1]x2
- float [0, 1]- Returns:
- new color that is determined by x1 and x2
-