Package colorblind
Class ColorUtilities
java.lang.Object
colorblind.ColorUtilities
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatapplyGammaCorrection(float s, float gamma) Apply Gamma Correctionstatic floatapplyGammaCorrectionStandardRGB(float s) Apply Standard Gamma Correctionstatic floatclip(float x) Simple utility function that is used in a couple of places.static floatclip(float x, float min, float max) Simple utility function that is used in a couple of places.static intconfusingDeuteranopiaColor(int color, float x) static intconfusingDichromaticColor(Deficiency colorBlindness, int color, float x) Intentionally generate colors that would be confusing to a colorblind person.static intconfusingMonochromaticColor(Deficiency colorBlindness, int color, float x1, float x2) Intentionally generate colors that would be confusing to someone with monochromatic vision.static intconfusingProtanopiaColor(int color, float x) static intconfusingTritanopiaColor(int color, float x) static VectorconvertLinearRGB2LMS(Vector rgbColor) static intconvertLinearRGB2PColor(Vector rgbColor) static VectorconvertLMS2LinearRGB(Vector lmsColor) static intconvertLMS2PColor(Vector lmsColor) static VectorconvertPColor2LinearRGB(int color) static VectorconvertPColor2LMS(int color) static floatlmsFeasibleBisectionSearch(Vector lms, int index, int direction) Search the LMS color space for the feasibility edge.static floatremoveGammaCorrection(float s, float gamma) Remove Gamma Correctionstatic floatremoveGammaCorrectionStandardRGB(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
-