Package colorblind

Class ColorUtilities

java.lang.Object
colorblind.ColorUtilities

public class ColorUtilities extends Object
  • Field Details

    • protanopiaSim

      public static Matrix protanopiaSim
    • deuteranopiaSim

      public static Matrix deuteranopiaSim
    • tritanopiaSim

      public static Matrix tritanopiaSim
    • achromatopsiaSim

      public static Vector achromatopsiaSim
    • blueConeMonochromacySim

      public static Vector blueConeMonochromacySim
    • customSim

      public static Matrix customSim
    • shiftTowardsVisible

      public static Matrix shiftTowardsVisible
    • rgb2lms

      public static Matrix rgb2lms
    • lms2rgb

      public static Matrix 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

      public static Vector convertLinearRGB2LMS(Vector rgbColor)
    • convertLMS2LinearRGB

      public static Vector convertLMS2LinearRGB(Vector lmsColor)
    • convertPColor2LinearRGB

      public static Vector convertPColor2LinearRGB(int color)
    • convertPColor2LMS

      public static Vector convertPColor2LMS(int color)
    • convertLinearRGB2PColor

      public static int convertLinearRGB2PColor(Vector rgbColor)
    • convertLMS2PColor

      public static int convertLMS2PColor(Vector lmsColor)
    • confusingDichromaticColor

      public static int confusingDichromaticColor(Deficiency colorBlindness, int color, float x)
      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 deficiency
      color - initial color
      x - 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

      public static float lmsFeasibleBisectionSearch(Vector lms, int index, int direction)
      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 space
      index - index into lms vector to change
      direction - 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 color
      x1 - float [0, 1]
      x2 - float [0, 1]
      Returns:
      new color that is determined by x1 and x2