Interface ColorSpaceTransform

  • All Known Implementing Classes:
    IPT, SRLAB2, XYZ

    public interface ColorSpaceTransform
    Defines the interface for color space transformations, enabling conversion to and from the RGB color space. Implementations should particularly focus on optimizing the toRGB(double[]) method for efficient conversion.
    Author:
    Michael Carleton
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      double[] fromRGB​(double[] RGB)
      Converts an RGB color into the corresponding color in the target color space.
      default double[] interpolateLinear​(double[] a, double[] b, double step, double[] out)
      Performs linear interpolation between two colors in an implementation-independent manner.
      double[] toRGB​(double[] color)
      Converts a color from the implementing color space to RGB.
    • Method Detail

      • toRGB

        double[] toRGB​(double[] color)
        Converts a color from the implementing color space to RGB. Implementations should focus on optimizing this conversion process for efficiency.
        Parameters:
        color - an array representing the color in the implementing color space. The specific meaning and length of this array depend on the color space.
        Returns:
        an array of three doubles representing the color in RGB, with each component normalized to the range [0, 1]. The output may exceed this range before display calibration or clipping is applied.
      • fromRGB

        double[] fromRGB​(double[] RGB)
        Converts an RGB color into the corresponding color in the target color space.
        Parameters:
        RGB - an array of three doubles representing the red, green, and blue components of the color, each normalized to the range [0, 1]
        Returns:
        an array of doubles representing the color in the target color space. The length and interpretation of this array depend on the specific color space.
      • interpolateLinear

        default double[] interpolateLinear​(double[] a,
                                           double[] b,
                                           double step,
                                           double[] out)
        Performs linear interpolation between two colors in an implementation-independent manner. This method is designed to work across different color spaces, providing a generic approach to color blending. Specific color space implementations (like HSB) may override this method if a more accurate or appropriate interpolation technique is required.
        Parameters:
        a - an array of doubles representing the starting color in the color space
        b - an array of doubles representing the ending color in the color space
        step - a double value between 0.0 and 1.0 representing the interpolation factor, where 0.0 corresponds to the starting color, 1.0 to the ending color, and values in between to intermediate colors
        out - an array of doubles where the interpolated color will be stored. This array must be pre-allocated and of appropriate length for the color space
        Returns:
        the out array containing the interpolated color