Class LabColorSpace

  • All Implemented Interfaces:
    Serializable

    public class LabColorSpace
    extends ColorSpace

    Represents the CIE 1976 (L*, a*, b*) or "CIELAB" device-independent ColorSpace. Colors from this ColorSpace can be used like any other color from the RGB or CMYK ColorSpaces, although they are most useful when specifying alternates for Spot colors.

    Technically you also need to specify the CIE illuminant to completely define the color, but usually the intention is to define an exact color for print output, so the D50 illuminant is assumed. If you require a D65 illuminant the getColorD65(float, float, float) method can be called.

    For example, here are three ways to specify the Color "PANTONE® Reflex Blue C" - the first using L*a*b values in CIELAB space with a D50 illuminant, the second in the same space with a D65 illuminant, and the third using a CMYK process colorspace. Note that the third approach is an approximation only as this particular shade can not normally be reproduced using a four-color process, which is why using Lab colors as alternatives for Spot colors is the best option if possible.

     Color blue = SpotColorSpace.getInstance("Pantone Reflex Blue C", LabColorSpace.getColor(19, 26, -68));
     Color blue = SpotColorSpace.getInstance("Pantone Reflex Blue C", LabColorSpace.getColorD65(26.18, 18.64, -59.93));
     Color blue = SpotColorSpace.getInstance("Pantone Reflex Blue C", CMYKColorSpace.getColor(1, 0.73f, 0, 0.02f));
     
    Since:
    2.14.1
    See Also:
    Serialized Form
    • Method Detail

      • getInstance

        public static final LabColorSpace getInstance()
        Return a standard instance of the Lab Colorspace, with a D50 whitepoint
        Since:
        2.26
      • toRGB

        public float[] toRGB​(float[] lab)
        Specified by:
        toRGB in class ColorSpace
      • fromRGB

        public float[] fromRGB​(float[] rgb)
        Specified by:
        fromRGB in class ColorSpace
      • fromCIEXYZ

        public float[] fromCIEXYZ​(float[] xyz)
        Specified by:
        fromCIEXYZ in class ColorSpace
      • toCIEXYZ

        public float[] toCIEXYZ​(float[] lab)
        Note this method will typically be called when converting a bitmap, and we have to map from
        Specified by:
        toCIEXYZ in class ColorSpace
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getColor

        public static Color getColor​(float L,
                                     float a,
                                     float b)
        Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant. This is usually the correct method to get a Lab color for use as an alternate for a SpotColorSpace Spot color, for instance.
        Parameters:
        L - the "L" value, which will be clipped to the range 0..100
        a - the "a" value, which will be clipped to the range -100..100
        b - the "b" value, which will be clipped to the range -100..100
      • getColor

        public static Color getColor​(float L,
                                     float a,
                                     float b,
                                     float alpha)
        Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant. This is usually the correct method to get a Lab color for use as an alternate for a SpotColorSpace Spot color, for instance.
        Parameters:
        L - the "L" value, which will be clipped to the range 0..100
        a - the "a" value, which will be clipped to the range -100..100
        b - the "b" value, which will be clipped to the range -100..100
        alpha - the alpha value from 0..1
      • getColorD65

        public static Color getColorD65​(float L,
                                        float a,
                                        float b)
        Get a Color in the CIELAB ColorSpace, based on the D65 illuminant.
        Parameters:
        L - the "L" value, which will be clipped to the range 0..100
        a - the "a" value, which will be clipped to the range -100..100
        b - the "b" value, which will be clipped to the range -100..100
      • convertGradient

        public static List<Map.Entry<Float,​Color>> convertGradient​(List<Map.Entry<Float,​Color>> in,
                                                                         ColorSpace target,
                                                                         float tolerance)
        Given a list of [Fraction,Color] pairs in one (or more) ColorSpaces representing a Gradient, return a List representing the same gradient in the specified target ColorSpace, ensuring that each Color is within the specified DeltaE-94 tolerance. If the Colors in the source list are in multiple spaces, they will be interpolated in the Lab ColorSpace. This method is definitely not for general use.
        Parameters:
        in - the list of [t, color] pairs, where t is a value from 0..1 indicating the location in the gradient, and color is the color at that point. The "t" values must be strictly ascending.
        target - the target colorspace which all the colors will be converted to
        tolerance - the distance from the original in CIE94 we allow. Suggest value of 1..3
        Since:
        2.24.1