Class PiecewiseLinearCdf

java.lang.Object
imagingbook.common.histogram.PiecewiseLinearCdf

public class PiecewiseLinearCdf extends Object

This class represents a discrete "cumulative distribution function" that is piecewise linear. See Sec. 3.6.3 (Fig. 3.12) of [1] for additional details.

[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).

  • Constructor Summary

    Constructors
    Constructor
    Description
    PiecewiseLinearCdf(int K, int[] a, double[] b)
    Constructor, creates a PiecewiseLinearCdf from a sequence of brightness / cumulative probability pairs.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    Returns the cumulative probabilities for the intensity values 0 to 255 as a double[].
    double
    getCdf(int i)
    Returns the cumulative probability for the specified intensity value.
    double
    getInverseCdf(double P)
    Returns the inverse cumulative probability function a = P-1(a), that is, the intensity value a associated with a given cum.
    double[]
    Returns the probability function for this distribution as a discrete array of probabilities.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PiecewiseLinearCdf

      public PiecewiseLinearCdf(int K, int[] a, double[] b)

      Constructor, creates a PiecewiseLinearCdf from a sequence of brightness / cumulative probability pairs. See Sec. 3.6.3 (Fig. 3.12) of [1] for additional details. Usage example:

       int[] ik = {28, 75, 150, 210};
       double[] Pk = {.05, .25, .75, .95};
       PiecewiseLinearCdf pLCdf = new PiecewiseLinearCdf(256, ik, Pk);

      [1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).

      Parameters:
      K - number of brightness values (typ. 256)
      a - a sequence of brightness values serving as control points
      b - a sequence of cumulative probability values in [0,1], one for each control point
  • Method Details

    • getCdf

      public double getCdf(int i)
      Returns the cumulative probability for the specified intensity value.
      Parameters:
      i - the intensity value
      Returns:
      the associated cumulative probability
    • getCdf

      public double[] getCdf()
      Returns the cumulative probabilities for the intensity values 0 to 255 as a double[].
      Returns:
      the array of cumulative probabilities
    • getInverseCdf

      public double getInverseCdf(double P)
      Returns the inverse cumulative probability function a = P-1(a), that is, the intensity value a associated with a given cum. probability P.
      Parameters:
      P - a cumulative probability
      Returns:
      the associated intensity
    • getPdf

      public double[] getPdf()
      Returns the probability function for this distribution as a discrete array of probabilities.
      Returns:
      the probability array