Class ColorLab


  • public class ColorLab
    extends java.lang.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:
    ColorXyz
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double epsilon  
      static float epsilon_f  
      static double kappa  
      static float kappa_f  
      static double Xr  
      static float Xr_f  
      static double Yr  
      static float Yr_f  
      static double Zr  
      static float Zr_f  
    • Constructor Summary

      Constructors 
      Constructor Description
      ColorLab()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      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 boofcv.struct.image.ImageGray<T>>
      void
      labToRgb​(boofcv.struct.image.Planar<boofcv.struct.image.GrayF32> lab, boofcv.struct.image.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 boofcv.struct.image.ImageGray<T>>
      void
      rgbToLab​(boofcv.struct.image.Planar<T> rgb, boofcv.struct.image.Planar<boofcv.struct.image.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
    • Constructor Detail

      • ColorLab

        public ColorLab()
    • Method Detail

      • 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 boofcv.struct.image.ImageGray<T>> void rgbToLab​(boofcv.struct.image.Planar<T> rgb,
                                                                                 boofcv.struct.image.Planar<boofcv.struct.image.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 boofcv.struct.image.ImageGray<T>> void labToRgb​(boofcv.struct.image.Planar<boofcv.struct.image.GrayF32> lab,
                                                                                 boofcv.struct.image.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