All Implemented Interfaces:
Serializable

public class GradationCurve extends NaturalCubicSpline1D implements Serializable
This class represents a gradation curve which can be used to map pixel intensity values to rendered intensities. Like its ancestor, NaturalCubicSpline1D, the GradationCurve is defined by a set of control points which may be set, removed and modified. However, the control points are subject to certain restrictions which are due to the nature of a GradationCurve:
  • x and y values of the control points must be in the range [0..255]
  • with x1 being the x value of control point p and x2 the one of p+1, the condition x2>x1 must hold.
  • the curve may be evaluated in the range [0..255]
  • for x values within two control points x1, x2, the value is calculated by fitting the natural cubic spline which achieves a smooth transition at the points (first derivatives left and right of the control point are equal and second derivatives are zero)
  • with n0 being the first control point and pn being the last one, y=y0 for x<x0 and y=yn for x>xn
  • there are at least two control points
See Also:
  • Constructor Details

    • GradationCurve

      public GradationCurve()
      Create a new GradationCurve which is initialised as a linear identity curve.
    • GradationCurve

      public GradationCurve(GradationCurve gradCurve)
      Create a new GradationCurve as clone of a given gradation curve.
      Parameters:
      gradCurve - The object to be cloned.
    • GradationCurve

      public GradationCurve(Polygon points)
      Create a new GradationCurve based on a given set of control points. This constructor is used to clone the curve only.
      Parameters:
      points - the set of control points defined by a Polygon
  • Method Details

    • addControlPoint

      public int addControlPoint(Point p)
      Description copied from class: ControlCurve
      Adds a control point to the end of the list.
      Overrides:
      addControlPoint in class ControlCurve
      Parameters:
      p - the Pointto add
      Returns:
      The total number of control points.
      See Also:
      • The addition makes sure that the x values of the points are ascending.
    • getControlPoint

      public Point getControlPoint(int n)
      Description copied from class: ControlCurve
      Gets a specified control point.
      Overrides:
      getControlPoint in class ControlCurve
      Parameters:
      n - The index of the point in question.
      Returns:
      The control point at the given index.
      See Also:
      • ControlCurve.getControlPoint(int)
    • insertControlPoint

      public int insertControlPoint(int n, Point p)
      Description copied from class: ControlCurve
      Inserts a control point at a given location.
      Overrides:
      insertControlPoint in class ControlCurve
      Parameters:
      n - the position to insert at
      p - the Pointto insert
      Returns:
      The total number of control points.
      See Also:
      • The insertion makes sure that the x values of the points are ascending, if necessary, the x value is modified.
    • removeControlPoint

      public void removeControlPoint(int n)
      Description copied from class: ControlCurve
      Removes the specified control point.
      Overrides:
      removeControlPoint in class ControlCurve
      Parameters:
      n - the index of the point to remove
      See Also:
      • ControlCurve.removeControlPoint(int)
    • reset

      public void reset()
      Removes all intermediate controls points and keeps just a start and end point for this curve.
    • setControlPoint

      public void setControlPoint(int n, Point p)
      Description copied from class: ControlCurve
      Sets the specified control point.
      Overrides:
      setControlPoint in class ControlCurve
      Parameters:
      n - the index of the point to modify
      p - the Pointto set
      See Also:
      • The modification makes sure that the x values of the points are ascending, if necessary, the x value is modified.
    • getValueAt

      public int getValueAt(int x)
      Get the intensity value for a given point. The curve is automatically mirrored around the zero point.
      Parameters:
      x - The point in question.
      Returns:
      The intensity.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • isLinearIdentity

      public boolean isLinearIdentity()
      Returns whether this curve is a identity curve
      Returns:
      boolean flag
    • hashCode

      public int hashCode()
      Calculate a hash code based on all points on the curve.
      Overrides:
      hashCode in class Object
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • getLookupTable

      public byte[] getLookupTable(int size)
      Return a lookup table based on the curve in the range 0...size. Lookup value interpretation: x=0 - black, x=255 - white.
      Parameters:
      size - The size of the lookup table.
      Returns:
      A lookup table.
    • computeCurve

      protected void computeCurve()
      Overrides:
      computeCurve in class NaturalCubicSpline1D