Class RankProcessors

java.lang.Object
net.algart.matrices.morphology.RankProcessors

public class RankProcessors extends Object

A set of streaming aperture processors, implementing all operations, specified in RankMorphology interface.

This class cannot be instantiated.

Author:
Daniel Alievsky
  • Method Details

    • getPercentiler

      public static StreamingApertureProcessor getPercentiler(ArrayContext context, boolean interpolated, int... bitLevels)
      Creates a new streaming aperture processor, which finds the percentile of the source matrix M. See comments to RankMorphology, section 4 about the "percentile" term. The real index r of the percentile for every element of the result is equal to the corresponding element of the additional matrix M0.

      More precisely, let rm is an instance of BasicRankMorphology, created by the call

      rm = BasicRankMorphology.getInstance(ArrayContext context, double dilationLevel, CustomRankPrecision precision),

      so that context, precision.interpolated() and precision.bitLevels() are the same as the arguments of this method. Then in the streaming aperture processor, created by this method:

      This processor is really created and called in the implementation of asPercentile and percentile methods in BasicRankMorphology class.

      Parameters:
      context - the context that will be used by this object; may be null, then it will be ignored.
      interpolated - the histogram model used while calculating percentile: true means the precise histogram model, false means the simple histogram model (see comments to Histogram class).
      bitLevels - the bit levels used while calculations.
      Returns:
      the new streaming aperture processor, finding the percentile.
      Throws:
      NullPointerException - if bitLevels argument is null.
      IllegalArgumentException - if bitLevels.length==0, or if bitLevels.length>31, or if some of elements bitLevels is not in 1..30 range, or if bitLevels[k]>=bitLevels[k+1] for some k.
    • getRanker

      public static StreamingApertureProcessor getRanker(ArrayContext context, boolean interpolated, int... bitLevels)
      Creates a new streaming aperture processor, which finds the rank of the source matrix M. See comments to RankMorphology, section 4 about the "rank" term. The real value v for every element of the result is equal to the corresponding element of the additional matrix M0.

      More precisely, let rm is an instance of BasicRankMorphology, created by the call

      rm = BasicRankMorphology.getInstance(ArrayContext context, double dilationLevel, CustomRankPrecision precision),

      so that context, precision.interpolated() and precision.bitLevels() are the same as the arguments of this method. Then in the streaming aperture processor, created by this method:

      • the number of required additional matrices is 1;
      • asProcessed method is equivalent to rm.asRank(requiredType, M, M0, P), where requiredType is the first argument of asProcessed method;
      • process method is equivalent to rm.rank(R, M, M0, P).

      This processor is really created and called in the implementation of asRank and rank methods in BasicRankMorphology class.

      Parameters:
      context - the context that will be used by this object; may be null, then it will be ignored.
      interpolated - the histogram model used while calculating percentile: true means the precise histogram model, false means the simple histogram model (see comments to Histogram class).
      bitLevels - the bit levels used while calculations.
      Returns:
      the new streaming aperture processor, finding the rank.
      Throws:
      NullPointerException - if bitLevels argument is null.
      IllegalArgumentException - if bitLevels.length==0, or if bitLevels.length>31, or if some of elements bitLevels is not in 1..30 range, or if bitLevels[k]>=bitLevels[k+1] for some k.
    • getAveragerBetweenPercentiles

      public static StreamingApertureProcessor getAveragerBetweenPercentiles(ArrayContext context, double filler, boolean interpolated, int... bitLevels)
      Creates a new streaming aperture processor, which finds the mean between 2 percentiles of the source matrix M. See comments to RankMorphology, section 4 about the "mean between 2 percentiles" term. The real indexes r1 and r2 of the percentiles for every element of the result are equal to the corresponding elements of the additional matrices M0 and M1.

      More precisely, let rm is an instance of BasicRankMorphology, created by the call

      rm = BasicRankMorphology.getInstance(ArrayContext context, double dilationLevel, CustomRankPrecision precision),

      so that context, precision.interpolated() and precision.bitLevels() are the same as the arguments of this method. Then in the streaming aperture processor, created by this method:

      This processor is really created and called in the implementation of asMeanBetweenPercentiles and meanBetweenPercentiles methods in BasicRankMorphology class.

      Parameters:
      context - the context that will be used by this object; may be null, then it will be ignored.
      filler - the reserved value, returned when r1r2.
      interpolated - the histogram model used while calculating percentile: true means the precise histogram model, false means the simple histogram model (see comments to Histogram class).
      bitLevels - the bit levels used while calculations.
      Returns:
      the new streaming aperture processor, finding the mean between 2 percentiles.
      Throws:
      NullPointerException - if bitLevels argument is null.
      IllegalArgumentException - if bitLevels.length==0, or if bitLevels.length>31, or if some of elements bitLevels is not in 1..30 range, or if bitLevels[k]>=bitLevels[k+1] for some k.
    • getAveragerBetweenValues

      public static StreamingApertureProcessor getAveragerBetweenValues(ArrayContext context, double filler, boolean interpolated, int... bitLevels)
      Creates a new streaming aperture processor, which finds the mean between 2 values of the source matrix M. See comments to RankMorphology, section 4 about the "mean between 2 values" term. The real numbers v1 and v2 for every element of the result are equal to the corresponding elements of the additional matrices M0 and M1.

      More precisely, let rm is an instance of BasicRankMorphology, created by the call

      rm = BasicRankMorphology.getInstance(ArrayContext context, double dilationLevel, CustomRankPrecision precision),

      so that context, precision.interpolated() and precision.bitLevels() are the same as the arguments of this method. Then in the streaming aperture processor, created by this method:

      • the number of required additional matrices is 2;
      • asProcessed method is equivalent to R=rm.asMeanBetweenValues(M, M0, M1, P, filler) (where filler is the argument of this method), if the requiredType argument of asProcessed method is equal to M.type()==R.type();
      • if requiredType is not equal to M.type(), it analogously calculates the mean between values with maximal (double) precision and then casts the floating-point results to the desired element type by the same rules as Arrays.asFuncArray(boolean, Func, Class, PArray...) method with the argument truncateOverflows=true; note that such result cannot be obtained by RankMorphology methods;
      • process method is equivalent to rm.meanBetweenValues(R, M, M0, M1, P, filler) (where filler is the argument of this method).

      This processor is really created and called in the implementation of asMeanBetweenValues and meanBetweenValues methods in BasicRankMorphology class.

      Parameters:
      context - the context that will be used by this object; may be null, then it will be ignored.
      filler - the reserved value, returned when r(v1*σ)≥r(v2*σ), or one of the special keys RankMorphology.FILL_MIN_VALUE, RankMorphology.FILL_MAX_VALUE, RankMorphology.FILL_NEAREST_VALUE, which mean using of special calculation modes B, C, D.
      interpolated - the histogram model used while calculating percentile: true means the precise histogram model, false means the simple histogram model (see comments to Histogram class).
      bitLevels - the bit levels used while calculations.
      Returns:
      the new streaming aperture processor, finding the mean between 2 values.
      Throws:
      NullPointerException - if bitLevels argument is null.
      IllegalArgumentException - if bitLevels.length==0, or if bitLevels.length>31, or if some of elements bitLevels is not in 1..30 range, or if bitLevels[k]>=bitLevels[k+1] for some k.
    • getSummator

      public static StreamingApertureProcessor getSummator(ArrayContext context, Func processingFunc)
      Creates a new streaming aperture processor, which finds the result of some given function f(S) of the aperture sum S of the source matrix M. See comments to RankMorphology, section 4 about the "aperture sum" term.

      More precisely, let rm is an instance of BasicRankMorphology, created by the call

      rm = BasicRankMorphology.getInstance(ArrayContext context, double dilationLevel, CustomRankPrecision precision),

      so that context is the same as the argument of this method and other argument are any (they do not affect calculating the aperture sum). Then in the streaming aperture processor, created by this method:

      • no additional matrices are required;
      • asProcessed method is equivalent to R=rm.asFunctionOfSum(M, P, processingFunc) (where processingFunc is the argument of this method), if the requiredType argument of asProcessed method is equal to M.type()==R.type();
      • if requiredType is not equal to M.type(), it analogously calculates the function f(S) of the aperture sum S with maximal (double) precision and then casts the floating-point results to the desired element type by the same rules as Arrays.asFuncArray(boolean, Func, Class, PArray...) method with the argument truncateOverflows=true; note that such result cannot be obtained by RankMorphology methods;
      • process method is equivalent to rm.functionOfSum(R, M, P, processingFunc) (where processingFunc is the argument of this method).

      This processor is really created and called in the implementation of asFunctionOfSum and functionOfSum methods in BasicRankMorphology class.

      Parameters:
      context - the context that will be used by this object; may be null, then it will be ignored.
      processingFunc - the function, which should be applied to every calculated aperture sum.
      Returns:
      the new streaming aperture processor, finding the given function of the aperture sum.
      Throws:
      NullPointerException - if bitLevels argument is null.
      IllegalArgumentException - if bitLevels.length==0, or if bitLevels.length>31, or if some of elements bitLevels is not in 1..30 range, or if bitLevels[k]>=bitLevels[k+1] for some k.
    • getPercentilePairProcessor

      public static StreamingApertureProcessor getPercentilePairProcessor(ArrayContext context, Func processingFunc, boolean interpolated, int... bitLevels)
      Creates a new streaming aperture processor, which finds the result of some given function f(v0, v1,v2) of some matrix M0 and two percentiles v1,v2 of the source matrix M. See comments to RankMorphology, section 4 about the "percentile" term. The real indexes r of two percentiles for every element of the result are equal to the corresponding elements of the additional matrices M1 and M2.

      More precisely, let rm is an instance of BasicRankMorphology, created by the call

      rm = BasicRankMorphology.getInstance(ArrayContext context, double dilationLevel, CustomRankPrecision precision),

      so that context, precision.interpolated() and precision.bitLevels() are the same as the arguments of this method. Then in the streaming aperture processor, created by this method:

      • the number of required additional matrices is 3;
      • asProcessed method is equivalent to R=rm.asFunctionOfPercentilePair(M, M1, M2, P, processingFunc) (where processingFunc is the argument of this method), if M0==M and the requiredType argument of asProcessed method is equal to M.type()==R.type();
      • if requiredType is not equal to M.type(), it analogously calculates the function f(v0, v1,v2) of the matrix M0 and two percentiles v1,v2 of the source matrix M with maximal (double) precision and then casts the floating-point results to the desired element type by the same rules as Arrays.asFuncArray(boolean, Func, Class, PArray...) method with the argument truncateOverflows=true;
      • if M0==M, process method is equivalent to rm.functionOfPercentilePair(R, M, M1, M2, P, processingFunc) (where processingFunc is the argument of this method), in other case if works analogously, but gets the first argument of f function from M0 matrix instead of M.

      Note that this processor, unlike RankMorphology.asFunctionOfPercentilePair and RankMorphology.functionOfPercentilePair methods, allows to use any matrix M0 as the source of first arguments of the function f(v0, v1,v2). (Those methods always get the first function argument from the source M matrix.)

      This processor is really created and called in the implementation of asFunctionOfPercentilePair and functionOfPercentilePair methods in BasicRankMorphology class. Those methods pass the same src matrix to this processor twice: as the main source matrix M and as the first additional matrix M0.

      Parameters:
      context - the context that will be used by this object; may be null, then it will be ignored.
      processingFunc - the function, which should be applied to every three (v0,v1,v2), where v0 is the element of M0 matrix, v1 and v2 are the corresponding percentiles of the source M matrix.
      interpolated - the histogram model used while calculating percentiles: true means the precise histogram model, false means the simple histogram model (see comments to Histogram class).
      bitLevels - the bit levels used while calculations.
      Returns:
      the new streaming aperture processor, finding the given function of the additional matrix M0 and the pair of percentiles.
      Throws:
      NullPointerException - if bitLevels argument is null.
      IllegalArgumentException - if bitLevels.length==0, or if bitLevels.length>31, or if some of elements bitLevels is not in 1..30 range, or if bitLevels[k]>=bitLevels[k+1] for some k.