Interface CustomRankPrecision

All Known Implementing Classes:
RankPrecision

public interface CustomRankPrecision

Complete description of precision characteristics of rank operations, described in RankMorphology interface. Usually this interface is used for instantiating BasicRankMorphology class by BasicRankMorphology.getInstance(net.algart.arrays.ArrayContext, double, net.algart.matrices.morphology.CustomRankPrecision) method.

This package offers RankPrecision class, providing a ready set of instances of this interface, enough for most situations. If you need another precision parameters, not listed in that class, you can implement this interface yourself.

The classes, implementing this interface, are immutable and thread-safe: there are no ways to modify settings of the created instance.

Author:
Daniel Alievsky
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The maximal possible number of analyzed bits: 30.
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    The bit levels.
    boolean
    Selects the histogram model used while calculating rank characteristics: true means the precise histogram model, false means the simple histogram model.
    int
    Returns the last element of the bitLevels() array.
  • Field Details

    • MAX_NUMBER_OF_ANALYZED_BITS

      static final int MAX_NUMBER_OF_ANALYZED_BITS
      The maximal possible number of analyzed bits: 30. The bit levels, returned by bitLevels() method, must not be greater than this value; in other case, an attempt to create an instance of BasicRankMorphology will lead to IllegalArgumentException.
      See Also:
  • Method Details

    • bitLevels

      int[] bitLevels()
      The bit levels. (Here and below we shall designate this array as bitLevels.)

      The last element of this array bitLevels[bitLevels.length-1] is named the number of analysed bits and specifies the logarithm of the length of the histogram, used while calculating rank characteristics. More precisely, the length of the histogram is M=2μ, where μ = bitLevels[bitLevels.length-1] for floating-point matrix elements or μ = min(bitLevels[bitLevels.length-1], β) for fixed-point matrix elements, β = M.array().bitsPerElement(). See more details in comments to RankMorphology interface, section 3.

      First bitLevels.length-1 elements of this array, i.e. JArrays.copyOfRange(bitLevels,0,bitLevels.length-1), are passed as bitLevelsOfPyramid argument of Histogram.newIntHistogram or SummingHistogram.newSummingIntHistogram methods, when they are called for creating objects, which really calculate the rank characteristics, described in RankMorphology interface. In other words, first bitLevels.length-1 elements describe the levels of the pyramid of histograms: it is necessary for efficient processing large histograms, consisting of thousands or millions bars.

      This array must not be empty and must not contain more than 31 elements, and all its elements must be sorted in strictly increasing order: bitLevels[k]<bitLevels[k+1] for all k. The elements of this array must not exceed MAX_NUMBER_OF_ANALYZED_BITS limit.

      Below are possible examples of the array, returned by this method:

      • {8} — the rank operations will be performed with a simple histogram, consisting of 256 bars; this precision is enough for byte matrices, but usually too low for short, int or floating-point matrices;
      • {6, 12} — the rank operations will be performed with a two-level pyramid of histograms, consisting of 4096 bars (or min(4096,2β)=256 for byte matrices), which will be grouped by 64 bars into "wide" bars of the 2nd level; such a precision is enough for many application;
      • {8, 16, 24} — the rank operations will be performed with a three-level pyramid of histograms, consisting of 224=16777216 bars (or min(224,2β)=256 or 65636 for byte or short/char matrices), which will be grouped by 256 bars into "wide" bars of the 2nd level and by 65536 bars into "wide" bars of the 3rd levels; this precision is good for most applications;
      • {12, 24} — the rank operations will be performed with a two-level pyramid of histograms, consisting of 224=16777216 bars (or min(224,2β)=256 or 65636 for byte or short/char matrices), which will be grouped by 4096 bars into "wide" bars of the 2nd level; this precision is equivalent to the previous example, but usually provides better performance.

      Note that the situation, when some or even all elements of this array are greater than 2β, is not an error — it just will lead to unjustified slowing down of calculations, because some levels of the pyramid of histograms will contain only 1 "wide" bar.

      Returns:
      bit levels of the pyramid of histograms (all elements excepting the last one) and the maximal possible total number of analyzed bits μ=log2(histogram length) (the last element of this array).
      See Also:
    • numberOfAnalyzedBits

      int numberOfAnalyzedBits()
      Returns the last element of the bitLevels() array.
      Returns:
      the maximal possible total number of analyzed bits μ=log2(histogram length).
    • interpolated

      boolean interpolated()
      Selects the histogram model used while calculating rank characteristics: true means the precise histogram model, false means the simple histogram model. See comments to Histogram and SummingHistogram classes about these models.
      Returns:
      whether the rank operations should be performed in the precise histogram model.