Class ColorLab

java.lang.Object
boofcv.alg.color.ColorLab

public class ColorLab extends Object

Conversion between RGB and CIE LAB color space. LAB color is designed to approximate human vision. L for lightness and a and b for the color-opponent dimensions, The reference white used in the conversions below is D65.

Note:

  • L has a range of 0 to 100
  • L = 0 is black and L* = 100 is diffuse white

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
    static final float
     
    static final double
     
    static final float
     
    static final double
     
    static final float
     
    static final double
     
    static final float
     
    static final double
     
    static final float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    invTran(double t)
     
    static float
    invTran(float t)
     
    static void
    labToLinearRgb(double L, double a, double b, double[] linearRgb)
    Conversion from CEI LAB to gamma corrected linear RGB.
    static void
    labToLinearRgb(float L, float a, float b, float[] linearRgb)
    Conversion from CEI LAB to gamma corrected linear RGB.
    static void
    labToRgb(double L, double a, double b, double[] linearRgb, int[] rgb)
    Conversion of CEI LAB to 8-bit RGB.
    static void
    labToRgb(float L, float a, float b, float[] linearRgb, float[] rgb)
    Conversion of CEI LAB to 8-bit RGB.
    static void
    labToRgb(float L, float a, float b, float[] linearRgb, int[] rgb)
    Conversion of CEI LAB to 8-bit RGB.
    static <T extends ImageGray<T>>
    void
    labToRgb(Planar<GrayF32> lab, Planar<T> rgb)
    Convert a 3-channel Planar image from LAB into RGB.
    static void
    labToXyz(double L, double a, double b, double[] xyz)
    Convert CEI LAB to CEI XYZ color space
    static void
    labToXyz(float L, float a, float b, float[] xyz)
    Convert CEI LAB to CEI XYZ color space
    static void
    linearRgbToLab(double r, double g, double b, double[] lab)
    Conversion from gamma corrected linear RGB into CEI LAB.
    static void
    linearRgbToLab(float r, float g, float b, float[] lab)
    Conversion from gamma corrected linear RGB into LAB.
    static void
    rgbToLab(double r, double g, double b, float[] lab)
    Conversion from 8-bit RGB into CIE LAB.
    static void
    rgbToLab(int r, int g, int b, double[] lab)
    Conversion from 8-bit RGB into CIE LAB.
    static void
    rgbToLab(int r, int g, int b, float[] lab)
    Conversion from 8-bit RGB into CIE LAB.
    static <T extends ImageGray<T>>
    void
    rgbToLab(Planar<T> rgb, Planar<GrayF32> lab)
    Convert a 3-channel Planar image from RGB into LAB.
    static void
    xyzToLab(double X, double Y, double Z, double[] lab)
    Convert CEI XYZ to CEI LAB color space
    static void
    xyzToLab(float X, float Y, float Z, float[] lab)
    Convert CEI XYZ to CEI LAB color space

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ColorLab

      public ColorLab()
  • Method Details

    • rgbToLab

      public static void rgbToLab(int r, int g, int b, double[] lab)
      Conversion from 8-bit RGB into CIE LAB. 8-bit = range of 0 to 255.
    • rgbToLab

      public static void rgbToLab(int r, int g, int b, float[] lab)
      Conversion from 8-bit RGB into CIE LAB. 8-bit = range of 0 to 255.
    • rgbToLab

      public static void rgbToLab(double r, double g, double b, float[] lab)
      Conversion from 8-bit RGB into CIE LAB. 8-bit = range of 0 to 255.
    • labToRgb

      public static void labToRgb(double L, double a, double b, double[] linearRgb, int[] rgb)
      Conversion of CEI LAB to 8-bit RGB. Converts to linearRgb and then applies gamma correction.
      Parameters:
      linearRgb - (output) Workspace to store intermediate linearRgb results
      rgb - (output) 8-bit RGB color. 0 to 255
    • labToRgb

      public static void labToRgb(float L, float a, float b, float[] linearRgb, int[] rgb)
      Conversion of CEI LAB to 8-bit RGB. Converts to Linear RGB and then applies gamma correction.
      Parameters:
      linearRgb - (output) Workspace to store intermediate linearRgb results
      rgb - (output) 8-bit RGB color. 0 to 255
    • labToRgb

      public static void labToRgb(float L, float a, float b, float[] linearRgb, float[] rgb)
      Conversion of CEI LAB to 8-bit RGB. Converts to Linear RGB and then applies gamma correction.
      Parameters:
      linearRgb - (output) Workspace to store intermediate Linear RGB results
      rgb - (output) 8-bit RGB color. 0 to 255
    • labToLinearRgb

      public static void labToLinearRgb(float L, float a, float b, float[] linearRgb)
      Conversion from CEI LAB to gamma corrected linear RGB. Linear RGB values have a range of 0:1
    • labToLinearRgb

      public static void labToLinearRgb(double L, double a, double b, double[] linearRgb)
      Conversion from CEI LAB to gamma corrected linear RGB. Linear RGB values have a range of 0:1
    • xyzToLab

      public static void xyzToLab(double X, double Y, double Z, double[] lab)
      Convert CEI XYZ to CEI LAB color space
    • xyzToLab

      public static void xyzToLab(float X, float Y, float Z, float[] lab)
      Convert CEI XYZ to CEI LAB color space
    • labToXyz

      public static void labToXyz(double L, double a, double b, double[] xyz)
      Convert CEI LAB to CEI XYZ color space
    • labToXyz

      public static void labToXyz(float L, float a, float b, float[] xyz)
      Convert CEI LAB to CEI XYZ color space
    • invTran

      public static double invTran(double t)
    • invTran

      public static float invTran(float t)
    • linearRgbToLab

      public static void linearRgbToLab(double r, double g, double b, double[] lab)
      Conversion from gamma corrected linear RGB into CEI LAB. Normalized RGB values have a range of 0:1
    • linearRgbToLab

      public static void linearRgbToLab(float r, float g, float b, float[] lab)
      Conversion from gamma corrected linear RGB into LAB. Normalized RGB values have a range of 0:1
    • rgbToLab

      public static <T extends ImageGray<T>> void rgbToLab(Planar<T> rgb, Planar<GrayF32> lab)
      Convert a 3-channel Planar image from RGB into LAB. RGB is assumed to have a range from 0:255 NOTE: Input and output image can be the same instance.
      Parameters:
      rgb - (Input) 8-bit RGB encoded image. R = channel 0, G = channel 1, B = channel 2
      lab - (Output) LAB encoded image. L = channel 0, A = channel 1, B = channel 2
    • labToRgb

      public static <T extends ImageGray<T>> void labToRgb(Planar<GrayF32> lab, Planar<T> rgb)
      Convert a 3-channel Planar image from LAB into RGB. RGB will have a range from 0 to 255. NOTE: Input and output image can be the same instance.
      Parameters:
      lab - (Input) LAB encoded image. L = channel 0, A = channel 1, B = channel 2
      rgb - (Output) 8-bit RGB encoded image. R = channel 0, G = channel 1, B = channel 2