Package com.day.image

Class ColorCurve

java.lang.Object
com.day.image.ColorCurve

public class ColorCurve extends Object
The ColorCurve class is a container to provide color and tonality information. The main use of instances of this class is done in the MultitoneOp class, which uses instances of this class to convey information of colors and tonality of those colors to mix together.

Instances of this class contain a Color value and a tonality curve, which is a 256 element array of intensity values in the range [0..1], where 0 is no application of this color and 1 is full color intensity. The elements of the array map to image luminance, where element 0 is taken for pixels with most luminance and element 256 is taken for pixels with no luminance.

Since:
echidna
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The number of levels supported by instances of this class
  • Constructor Summary

    Constructors
    Constructor
    Description
    ColorCurve(ColorCurve colorCurve)
    Creates a copy of the ColorCurve instance.
    Creates a ColorCurve with the given color and the default mapping.
    ColorCurve(Color color, float[] curve)
    Creates a ColorCurve with the given color and an evenly spaced interval table based on list of intensity points.
    ColorCurve(Color color, float[] curve, float[] intervals)
    Creates a ColorCurve with the given color and an interval table based on list of intensity points where the interval distances is also specified.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the color associated with this instance.
    float
    getLevel(int step)
    Returns the intensity level for the given level.

    Methods inherited from class java.lang.Object

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

    • MAX_LEVEL

      public static final int MAX_LEVEL
      The number of levels supported by instances of this class
      See Also:
  • Constructor Details

    • ColorCurve

      public ColorCurve(ColorCurve colorCurve)
      Creates a copy of the ColorCurve instance. This copy constructor copies the values of the other instance. That is external modification of thos values has no influence on the newly created instance.
      Parameters:
      colorCurve -
    • ColorCurve

      public ColorCurve(Color color)
      Creates a ColorCurve with the given color and the default mapping. The default mapping maps luminosity levels to the same intensity levels.
      Parameters:
      color - The color to set in this ColorCurve.
    • ColorCurve

      public ColorCurve(Color color, float[] curve)
      Creates a ColorCurve with the given color and an evenly spaced interval table based on list of intensity points.

      Each entry of the curve parameter is in the range [0..1] and the length of the array is in the interval [2..256]. If the array has less than two entries it is ignored and the identity mapping is taken, if either an entry value is out of range or the curve array is longer than 256 entries, the result is undefined.

      Parameters:
      color - The color described by this descriptor
      curve - The intensity perecentages for equally distributed intervals or null to use the identity map.
    • ColorCurve

      public ColorCurve(Color color, float[] curve, float[] intervals)
      Creates a ColorCurve with the given color and an interval table based on list of intensity points where the interval distances is also specified.

      Each entry of the curve parameter is in the range [0..1] and the length of the array is in the interval [2..256]. If the array has less than two entries it is ignored and the identity mapping is taken, if either an entry value is out of range or the curve array is longer than 256 entries, the result is undefined.

      The intervals array must contain the one elements less than the curve array, that is the predicate curve.length - 1 == intervals.length must be true. If the intervals array is smaller or bigger than that, it is ignored and the points are evenyl spaced !

      The sum of entries of the intervals array defines the relative size of each interval. For example if the sum of the entries is 11, the first entry is 1, then the first intervall will take 23 steps, which is 256 * 1/11 because each step is 1/11th of the full range of 256.

      Parameters:
      color - The color described by this descriptor
      curve - The intensity perecentages for the intervals or null to use the identity map (in which case the intervals argument is ignored).
      intervals - Normalized intervalls of curve values or null to evenly space the itensity levels .
  • Method Details

    • getColor

      public Color getColor()
      Returns the color associated with this instance.
      Returns:
      the color associated with this instance.
    • getLevel

      public float getLevel(int step)
      Returns the intensity level for the given level.
      Parameters:
      step - The luminosity level for which to return this instances intensity level.
      Returns:
      The intensity level of this instance for the given luminosity.
      Throws:
      IndexOutOfBoundsException - if step is less than 0 or higher than MAX_LEVEL.