public class TiledRankMorphology extends TiledMorphology implements RankMorphology
The filter allowing to transform any RankMorphology
object to another instance of that interface,
which uses some given tiler
for processing the source matrices
(arguments of RankMorphology
methods).
This object is built on the base of some parent object,
implementing RankMorphology
, and some tiler (an instance of
TiledApertureProcessorFactory
class).
This object works almost identically to the parent object with the only difference,
that it uses the specified tiler for performing all operations.
More precisely, each method of this object creates an implementation p of ApertureProcessor
interface. The only thing, performed by
process
method of
that object p, is calling the same method of parent object with the arguments
of p.process(dest,src)
method
(the source matrix or matrices are retrieved from src, the result is saved into dest).
The dependence aperture p.dependenceAperture(...)
is calculated automatically on the base of the patterns and the performed operation.
Then, the method of this object executes the required operation with help of
tiler()
.tile
(p).process(dest,src)
The methods "asOperation", returning a view of the passed sources matrices
(like TiledMorphology.asDilation(Matrix, Pattern)
, asPercentile(Matrix, double, Pattern)
,
asRank(Class, Matrix, Matrix, Pattern)
, etc.) are an exception
from this rule. These methods of this class works in the same way, as in
ContinuedRankMorphology
class, the continuation mode of which is equal to
tiler()
.continuationMode()
.
Note: in improbable cases, when the dimensions of the source matrix and/or
the sizes of the pattern are extremely large (about 2^{63}),
so that the necessary appended matrices should have dimensions or total number of elements,
greater than TiledApertureProcessorFactory
class, "Restriction" section for precise details.
Of course, these are very improbable cases.
This class is immutable and threadsafe: there are no ways to modify settings of the created instance.
Morphology.SubtractionMode
FILL_MAX_VALUE, FILL_MIN_VALUE, FILL_NEAREST_VALUE
Modifier and Type  Method and Description 

Matrix<? extends PArray> 
asFunctionOfPercentilePair(Matrix<? extends PArray> src,
double percentileIndex1,
double percentileIndex2,
Pattern pattern,
Func processingFunc)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the result of some given function

Matrix<? extends PArray> 
asFunctionOfPercentilePair(Matrix<? extends PArray> src,
Matrix<? extends PArray> percentileIndexes1,
Matrix<? extends PArray> percentileIndexes2,
Pattern pattern,
Func processingFunc)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the result of some given function

Matrix<? extends PArray> 
asFunctionOfSum(Matrix<? extends PArray> src,
Pattern pattern,
Func processingFunc)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the result of some given function

Matrix<? extends PArray> 
asMean(Matrix<? extends PArray> src,
Pattern pattern)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the mean
of the source matrix by the specified pattern.

Matrix<? extends PArray> 
asMeanBetweenPercentiles(Matrix<? extends PArray> src,
double fromPercentileIndex,
double toPercentileIndex,
Pattern pattern,
double filler)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the mean between 2 percentiles
of the source matrix by the specified pattern.

Matrix<? extends PArray> 
asMeanBetweenPercentiles(Matrix<? extends PArray> src,
Matrix<? extends PArray> fromPercentileIndexes,
Matrix<? extends PArray> toPercentileIndexes,
Pattern pattern,
double filler)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the mean between 2 percentiles
of the source matrix by the specified pattern.

Matrix<? extends PArray> 
asMeanBetweenValues(Matrix<? extends PArray> src,
Matrix<? extends PArray> minValues,
Matrix<? extends PArray> maxValues,
Pattern pattern,
double filler)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the mean between 2 values
of the source matrix by the specified pattern.

Matrix<? extends PArray> 
asPercentile(Matrix<? extends PArray> src,
double percentileIndex,
Pattern pattern)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the percentile
of the source matrix by the specified pattern.

Matrix<? extends PArray> 
asPercentile(Matrix<? extends PArray> src,
Matrix<? extends PArray> percentileIndexes,
Pattern pattern)
Returns an immutable view of the passed source matrix,
such that any reading data from it calculates and returns the percentile
of the source matrix by the specified pattern.

<T extends PArray> 
asRank(java.lang.Class<? extends T> requiredType,
Matrix<? extends PArray> baseMatrix,
Matrix<? extends PArray> rankedMatrix,
Pattern pattern)
Returns an immutable view of the passed baseMatrix matrix,
such that any reading data from it calculates and returns the ranks
of some given values v regarding the source matrix baseMatrix with the specified pattern.

RankMorphology 
context(ArrayContext newContext)
Switches the context: returns an instance, identical to this one excepting
that it uses the specified newContext for all operations.

Matrix<? extends UpdatablePArray> 
functionOfPercentilePair(Matrix<? extends PArray> src,
double percentileIndex1,
double percentileIndex2,
Pattern pattern,
Func processingFunc)
Returns a new updatable matrix, containing the result of some given function

Matrix<? extends UpdatablePArray> 
functionOfPercentilePair(Matrix<? extends PArray> src,
Matrix<? extends PArray> percentileIndexes1,
Matrix<? extends PArray> percentileIndexes2,
Pattern pattern,
Func processingFunc)
Returns a new updatable matrix, containing the result of some given function

void 
functionOfPercentilePair(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
double percentileIndex1,
double percentileIndex2,
Pattern pattern,
Func processingFunc)
Equivalent to
RankMorphology.functionOfPercentilePair(Matrix, double, double, Pattern, Func) method,
but the result matrix will be placed in the dest argument. 
void 
functionOfPercentilePair(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
Matrix<? extends PArray> percentileIndexes1,
Matrix<? extends PArray> percentileIndexes2,
Pattern pattern,
Func processingFunc)
Equivalent to
RankMorphology.functionOfPercentilePair(Matrix, Matrix, Matrix, Pattern, Func) method,
but the result matrix will be placed in the dest argument. 
Matrix<? extends UpdatablePArray> 
functionOfSum(Matrix<? extends PArray> src,
Pattern pattern,
Func processingFunc)
Returns a new updatable matrix, containing the result of some given function

void 
functionOfSum(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
Pattern pattern,
Func processingFunc)
Equivalent to
RankMorphology.functionOfSum(Matrix, Pattern, Func) method,
but the result matrix will be placed in the dest argument. 
static TiledRankMorphology 
getInstance(RankMorphology parent,
TiledApertureProcessorFactory tiler)
Returns new instance of this class with the passed parent
RankMorphology object
and the specified processing tiler. 
Matrix<? extends UpdatablePArray> 
mean(Matrix<? extends PArray> src,
Pattern pattern)
Returns a new updatable matrix, containing the mean
of the source matrix by the specified pattern.

void 
mean(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
Pattern pattern)
Equivalent to
RankMorphology.mean(Matrix, Pattern) method,
but the result matrix will be placed in the dest argument. 
Matrix<? extends UpdatablePArray> 
meanBetweenPercentiles(Matrix<? extends PArray> src,
double fromPercentileIndex,
double toPercentileIndex,
Pattern pattern,
double filler)
Returns a new updatable matrix, containing the mean between 2 percentiles
of the source matrix by the specified pattern.

Matrix<? extends UpdatablePArray> 
meanBetweenPercentiles(Matrix<? extends PArray> src,
Matrix<? extends PArray> fromPercentileIndexes,
Matrix<? extends PArray> toPercentileIndexes,
Pattern pattern,
double filler)
Returns a new updatable matrix, containing the mean between 2 percentiles
of the source matrix by the specified pattern.

void 
meanBetweenPercentiles(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
double fromPercentileIndex,
double toPercentileIndex,
Pattern pattern,
double filler)
Equivalent to
RankMorphology.meanBetweenPercentiles(Matrix, double, double, Pattern, double) method,
but the result matrix will be placed in the dest argument. 
void 
meanBetweenPercentiles(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
Matrix<? extends PArray> fromPercentileIndexes,
Matrix<? extends PArray> toPercentileIndexes,
Pattern pattern,
double filler)
Equivalent to
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, Matrix, Pattern, double) method,
but the result matrix will be placed in the dest argument. 
Matrix<? extends UpdatablePArray> 
meanBetweenValues(Matrix<? extends PArray> src,
Matrix<? extends PArray> minValues,
Matrix<? extends PArray> maxValues,
Pattern pattern,
double filler)
Returns a new updatable matrix, containing the mean between 2 values
of the source matrix by the specified pattern.

void 
meanBetweenValues(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
Matrix<? extends PArray> minValues,
Matrix<? extends PArray> maxValues,
Pattern pattern,
double filler)
Equivalent to
RankMorphology.meanBetweenValues(Matrix, Matrix, Matrix, Pattern, double) method, but the result matrix
will be placed in the dest argument. 
RankMorphology 
parent()
Returns the parent
RankMorphology object,
passed to getInstance(RankMorphology, TiledApertureProcessorFactory) method. 
Matrix<? extends UpdatablePArray> 
percentile(Matrix<? extends PArray> src,
double percentileIndex,
Pattern pattern)
Returns a new updatable matrix, containing the percentile
of the source matrix by the specified pattern.

Matrix<? extends UpdatablePArray> 
percentile(Matrix<? extends PArray> src,
Matrix<? extends PArray> percentileIndexes,
Pattern pattern)
Returns a new updatable matrix, containing the percentile
of the source matrix by the specified pattern.

void 
percentile(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
double percentileIndex,
Pattern pattern)
Equivalent to
RankMorphology.percentile(Matrix, double, Pattern) method, but the result matrix
will be placed in the dest argument. 
void 
percentile(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> src,
Matrix<? extends PArray> percentileIndexes,
Pattern pattern)
Equivalent to
RankMorphology.percentile(Matrix, Matrix, Pattern) method, but the result matrix
will be placed in the dest argument. 
<T extends PArray> 
rank(java.lang.Class<? extends T> requiredType,
Matrix<? extends PArray> baseMatrix,
Matrix<? extends PArray> rankedMatrix,
Pattern pattern)
Returns a new updatable matrix, containing the rank
of some given values v regarding the source matrix baseMatrix with the specified pattern.

void 
rank(Matrix<? extends UpdatablePArray> dest,
Matrix<? extends PArray> baseMatrix,
Matrix<? extends PArray> rankedMatrix,
Pattern pattern)
Equivalent to
RankMorphology.rank(Class, Matrix, Matrix, Pattern) method, but the result matrix
will be placed in the dest argument and the required type will be chosen automatically
as type (PArray.class) 
asDilation, asErosion, beucherGradient, closing, context, dilation, dilation, dilation, dilation, dilationErosion, erosion, erosion, erosion, erosion, erosionDilation, getInstance, isPseudoCyclic, maskedDilationErosion, maskedErosionDilation, opening, tiler, weakDilation, weakErosion
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asDilation, asErosion, beucherGradient, closing, dilation, dilation, dilation, dilation, dilationErosion, erosion, erosion, erosion, erosion, erosionDilation, isPseudoCyclic, maskedDilationErosion, maskedErosionDilation, opening, weakDilation, weakErosion
context
public static TiledRankMorphology getInstance(RankMorphology parent, TiledApertureProcessorFactory tiler)
RankMorphology
object
and the specified processing tiler.
Note: the context
of the created object is retrieved from
parent.context()
, and
the context
of the passed tiler
is automatically replaced with the same one — the current tiler
of the created object is context
(newInstance.context()
)context
of the passed tiler is not important
and can be null.
parent
 parent object: the instance of Morphology
interface
that will perform all operations.tiler
 the tiler, which will be used for processing matrices by this class.java.lang.NullPointerException
 if parent or tiler argument is null.public RankMorphology parent()
RankMorphology
object,
passed to getInstance(RankMorphology, TiledApertureProcessorFactory)
method.parent
in class TiledMorphology
RankMorphology
object.public RankMorphology context(ArrayContext newContext)
subtask
of the full task.
More precisely, this method is equivalent to
getInstance
(parent()
.context
(newContext), tiler()
).
context
in interface ArrayProcessorWithContextSwitching
context
in interface Morphology
context
in interface RankMorphology
context
in class TiledMorphology
newContext
 another context, used by the returned instance; may be null.public Matrix<? extends PArray> asPercentile(Matrix<? extends PArray> src, Matrix<? extends PArray> percentileIndexes, Pattern pattern)
RankMorphology
comments to this class
, 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 percentileIndexes matrix.
The element type
of the created matrix is the same as the element type of the source one.
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real percentile
Histogram.iValue
(b, (long)Math.floor(r))Histogram.iPreciseValue
(b, r)array()
.bitsPerElement()
comments to this class
, section 3.
So, if μ is chosen less than the precision of this matrix β
(8 for byte, 16 for short, etc.), then BasicRankMorphology
object, μ is chosen while
instantiating this object
as asPercentile
in interface RankMorphology
src
 the source matrix.percentileIndexes
 the matrix containing r argument: the indexes of the percentile
for every element of the result.pattern
 the pattern: the shape of the aperture.RankMorphology.asPercentile(Matrix, double, Pattern)
,
RankMorphology.percentile(Matrix, Matrix, Pattern)
,
RankMorphology.percentile(Matrix, Matrix, Matrix, Pattern)
public Matrix<? extends PArray> asPercentile(Matrix<? extends PArray> src, double percentileIndex, Pattern pattern)
RankMorphology
comments to this class
, section 4 about the "percentile" term.
The real index r of the percentile is equal to percentileIndex argument for
all aperture positions. The element type
of the created matrix is the same as the element type of the source one.
This method is equivalent to
asPercentile
(src, src.matrix(Arrays.nDoubleCopies
(src.size(), percentileIndex), pattern)
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real percentile
Histogram.iValue
(b, (long)Math.floor(r))Histogram.iPreciseValue
(b, r)array()
.bitsPerElement()
comments to this class
, section 3.
So, if μ is chosen less than the precision of this matrix β
(8 for byte, 16 for short, etc.), then BasicRankMorphology
object, μ is chosen while
instantiating this object
as asPercentile
in interface RankMorphology
src
 the source matrix.percentileIndex
 r argument of the percentile.pattern
 the pattern: the shape of the aperture.RankMorphology.asPercentile(Matrix, Matrix, Pattern)
,
RankMorphology.percentile(Matrix, double, Pattern)
,
RankMorphology.percentile(Matrix, Matrix, double, Pattern)
public <T extends PArray> Matrix<T> asRank(java.lang.Class<? extends T> requiredType, Matrix<? extends PArray> baseMatrix, Matrix<? extends PArray> rankedMatrix, Pattern pattern)
RankMorphology
comments to this class
, section 4 about the "rank" term.
The real value v for every element of the result is equal
to the corresponding element of rankedMatrix matrix.
The matrix, returned by this method, is immutable, and the class of its builtin array
implements one of the basic interfaces
BitArray
, CharArray
,
ByteArray
, ShortArray
,
IntArray
, LongArray
,
FloatArray
or DoubleArray
.
The class of desired interface (one of 8 possible classes) must be passed as requiredType argument.
So, it defines the element type of the returned matrix.
The rules of casting the floatingpoint ranks to the desired element type are the same as in
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
The element types of baseMatrix and rankedMatrix are usually equal.
If they are different (elementType()
!=rankedMatrix.elementType()
Matrices.asFuncMatrix
(true,Func.IDENTITY
, baseMatrix.array().type()
, rankedMatrix)
before all other calculations. In other words, this method always casts the type of
the ranked elements to the type of baseMatrix elements.
As a result, we can be sure, that if the source baseMatrix matrix is fixedpoint
(boolean, char, byte, short, int or long elements),
then the rank pointCount()
asRank
in interface RankMorphology
requiredType
 the desired type of the builtin array in the returned matrix.baseMatrix
 the source matrix.rankedMatrix
 the matrix containing v argument: the values,
the rank of which should be calculated.pattern
 the pattern: the shape of the aperture.RankMorphology.rank(Class, Matrix, Matrix, Pattern)
,
RankMorphology.rank(Matrix, Matrix, Matrix, Pattern)
public Matrix<? extends PArray> asMeanBetweenPercentiles(Matrix<? extends PArray> src, Matrix<? extends PArray> fromPercentileIndexes, Matrix<? extends PArray> toPercentileIndexes, Pattern pattern, double filler)
RankMorphology
comments to this class
, section 4 about the
"mean between 2 percentiles" term.
The real indexes r_{1} and r_{2} of the percentiles
for every element of the result are equal to the corresponding elements of
fromPercentileIndexes and toPercentileIndexes matrices.
The reserved value filler is specified by the last argument of this method.
The element type
of the created matrix is the same as the element type of the source one.
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined in the comments to this class.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
asMeanBetweenPercentiles
in interface RankMorphology
src
 the source matrix.fromPercentileIndexes
 the matrix containing r_{1} argument: the indexes of
the less percentile of the averaged range for every element of the result.toPercentileIndexes
 the matrix containing r_{2} argument: the indexes of
the greater percentile of the averaged range for every element of the result.pattern
 the pattern: the shape of the aperture.filler
 the reserved value, returned when
RankMorphology.asMeanBetweenPercentiles(Matrix, double, double, Pattern, double)
,
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, Matrix, Pattern, double)
,
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, Matrix, Matrix, Pattern, double)
public Matrix<? extends PArray> asMeanBetweenPercentiles(Matrix<? extends PArray> src, double fromPercentileIndex, double toPercentileIndex, Pattern pattern, double filler)
RankMorphology
comments to this class
, section 4 about the
"mean between 2 percentiles" term.
The real indexes r_{1} and r_{2} of the percentiles
for every element of the result are equal to fromPercentileIndex
and toPercentileIndex arguments for all aperture positions.
The reserved value filler is specified by the last argument of this method.
The element type
of the created matrix is the same as the element type of the source one.
This method is equivalent to
asMeanBetweenPercentiles
(src, src.matrix(Arrays.nDoubleCopies
(src.size(), fromPercentileIndex), src.matrix(Arrays.nDoubleCopies
(src.size(), toPercentileIndex), pattern, filler)
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined in the comments to this class.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
asMeanBetweenPercentiles
in interface RankMorphology
src
 the source matrix.fromPercentileIndex
 r_{1} argument: the index of
the less percentile of the averaged range for every element of the result.toPercentileIndex
 r_{2} argument: the indexes of
the greater percentile of the averaged range for every element of the result.pattern
 the pattern: the shape of the aperture.filler
 the reserved value, returned when
RankMorphology.asMeanBetweenPercentiles(Matrix, Matrix, Matrix, Pattern, double)
,
RankMorphology.meanBetweenPercentiles(Matrix, double, double, Pattern, double)
,
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, double, double, Pattern, double)
public Matrix<? extends PArray> asMeanBetweenValues(Matrix<? extends PArray> src, Matrix<? extends PArray> minValues, Matrix<? extends PArray> maxValues, Pattern pattern, double filler)
RankMorphology
comments to this class
, section 4 about the
"mean between 2 values" term.
The real numbers v_{1} and v_{2}
for every element of the result are equal to the corresponding elements of
minValues and maxValues matrices.
The reserved value filler and the mode of calculation (for the case
RankMorphology.FILL_MIN_VALUE
(Double.NEGATIVE_INFINITY),
the mode B is used;RankMorphology.FILL_MAX_VALUE
(Double.POSITIVE_INFINITY),
the mode C is used;RankMorphology.FILL_NEAREST_VALUE
(Double.NaN),
the mode D is used;element type
of the created matrix is the same as the element type of the source one.
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined in the comments to this class.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
asMeanBetweenValues
in interface RankMorphology
src
 the source matrix.minValues
 the matrix containing v_{1} argument: the low bound
of the averaged range of values for every element of the result.maxValues
 the matrix containing v_{2} argument: the high bound
of the averaged range of values for every element of the result.pattern
 the pattern: the shape of the aperture.filler
 the reserved value, returned when
RankMorphology.FILL_MIN_VALUE
, RankMorphology.FILL_MAX_VALUE
,
RankMorphology.FILL_NEAREST_VALUE
, which mean using of special calculation modes B, C, D.RankMorphology.meanBetweenValues(Matrix, Matrix, Matrix, Pattern, double)
,
RankMorphology.meanBetweenValues(Matrix, Matrix, Matrix, Matrix, Pattern, double)
public Matrix<? extends PArray> asMean(Matrix<? extends PArray> src, Pattern pattern)
RankMorphology
More precisely, this method is equivalent to
asFunctionOfSum
(src, pattern, meanFunc)
LinearFunc.getInstance
(0.0, 1.0/N),
pointCount()
elementType()
LinearFunc.getInstance
(0.5, 1.0/N),
pointCount()
elementType()
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined above.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
The described rounding rule explains, why we add 0.5 to the mean in the case of a fixedpoint source
elements. Namely, in this case the combination of adding 0.5 and further truncation to the integer part
works as rounding to the nearest integer:
Note: the behaviour of this method is similar to
asMeanBetweenPercentiles
(src, 0, N, pattern, anyFiller),
where pointCount()
comments to SummingHistogram class
).
Really, in this case the mean between 2 percentiles is equal to
(S(r_{2})−S(r_{1})) / ((r_{2}−r_{1})*σ) = S(N) / (N*σ) = (Σ _{0≤j<M}(j+0.5)*b[j]) / (N*σ)
In the simplest case, when the source elements are real numbers in the "standard" allowed range
(Σ _{0≤i<N}(a_{i}+0.5)) / (NM) = (v'_{0}+v'_{1}+...+v'_{N−1}) / N + 0.5 / M ≈ (v_{0}+v_{1}+...+v_{N−1}) / N
where
In another simplest case, when the source elements are integer numbers, σ=1 and
the elements v_{i} are nonnegative integers,
we have
(Σ _{0≤i<N}(v_{i}+0.5)) / N = (v_{0}+v_{1}+...+v_{N−1}) / N + 0.5
asMean
in interface RankMorphology
src
 the source matrix.pattern
 the pattern: the shape of the aperture.RankMorphology.mean(Matrix, Pattern)
,
RankMorphology.mean(Matrix, Matrix, Pattern)
public Matrix<? extends PArray> asFunctionOfSum(Matrix<? extends PArray> src, Pattern pattern, Func processingFunc)
RankMorphology
comments to this class
, section 4 about the
"aperture sum" term.
The element type
of the created matrix is the same as the element type of the source one.
The function, applied to each calculated aperture sum S, is specified via
processingFunc argument. Namely, for each aperture position this method
calculates the aperture sum S of the source matrix and returns
get
(S)
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real function result.
In this case, the found function result f is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
This method can be considered as a generalization of RankMorphology.asMean(Matrix, Pattern)
.
asFunctionOfSum
in interface RankMorphology
src
 the source matrix.pattern
 the pattern: the shape of the aperture.processingFunc
 the function, which should be applied to every calculated aperture sum.RankMorphology.functionOfSum(Matrix, Pattern, Func)
,
RankMorphology.functionOfSum(Matrix, Matrix, Pattern, Func)
public Matrix<? extends PArray> asFunctionOfPercentilePair(Matrix<? extends PArray> src, Matrix<? extends PArray> percentileIndexes1, Matrix<? extends PArray> percentileIndexes2, Pattern pattern, Func processingFunc)
RankMorphology
comments to this class
, 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 percentileIndexes1 (for v_{1})
or percentileIndexes2 matrix (for v_{2}).
The element type
of the created matrix is the same as the element type of the source one.
The function, applied to each calculated three
get
(v,v_{1},v_{2})
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real function result.
In this case, the found function result f is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
You can get the same results by 2 calls of RankMorphology.asPercentile(Matrix, Matrix, Pattern)
method
for both matrices of percentile indexes and applying the function to them and to the source matrix via
Matrices.asFuncMatrix(Func, Class, Matrix, Matrix, Matrix)
ContrastingFunc
object as processingFunc argument.
asFunctionOfPercentilePair
in interface RankMorphology
src
 the source matrix.percentileIndexes1
 the 1st matrix containing r argument: the indexes of the 1st percentile
v_{1} for every element of the result.percentileIndexes2
 the 2nd matrix containing r argument: the indexes of the 2nd percentile
v_{2} for every element of the result.pattern
 the pattern: the shape of the aperture.processingFunc
 the function, which should be applied to every calculated three
RankMorphology.asFunctionOfPercentilePair(Matrix, double, double, Pattern, Func)
,
RankMorphology.functionOfPercentilePair(Matrix, Matrix, Matrix, Pattern, Func)
,
RankMorphology.functionOfPercentilePair(Matrix, Matrix, Matrix, Matrix, Pattern, Func)
public Matrix<? extends PArray> asFunctionOfPercentilePair(Matrix<? extends PArray> src, double percentileIndex1, double percentileIndex2, Pattern pattern, Func processingFunc)
RankMorphology
comments to this class
, section 4 about the "percentile" term.
The real indexes r of two percentiles for every element of the result are equal
to percentileIndex1 (for v_{1})
or percentileIndex2 argument (for v_{2}).
The element type
of the created matrix is the same as the element type of the source one.
This method is equivalent to
asFunctionOfPercentilePair
(src, src.matrix(Arrays.nDoubleCopies
(src.size(), percentileIndex1), src.matrix(Arrays.nDoubleCopies
(src.size(), percentileIndex1), pattern, processingFunc)
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real function result.
In this case, the found function result f is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
You can get the same results by 2 calls of RankMorphology.asPercentile(Matrix, double, Pattern)
method
for both matrices of percentile indexes and applying the function to them and to the source matrix via
Matrices.asFuncMatrix(Func, Class, Matrix, Matrix, Matrix)
ContrastingFunc
object as processingFunc argument.
asFunctionOfPercentilePair
in interface RankMorphology
src
 the source matrix.percentileIndex1
 the 1st r argument: the index of the 1st percentile v_{1}.percentileIndex2
 the 2nd r argument: the index of the 2nd percentile v_{2}.pattern
 the pattern: the shape of the aperture.processingFunc
 the function, which should be applied to every calculated three
RankMorphology.asFunctionOfPercentilePair(Matrix, Matrix, Matrix, Pattern, Func)
,
RankMorphology.functionOfPercentilePair(Matrix, double, double, Pattern, Func)
,
RankMorphology.functionOfPercentilePair(Matrix, Matrix, double, double, Pattern, Func)
public Matrix<? extends UpdatablePArray> percentile(Matrix<? extends PArray> src, Matrix<? extends PArray> percentileIndexes, Pattern pattern)
RankMorphology
comments to this class
, 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 percentileIndexes matrix.
The element type
of the created matrix is the same as the element type of the source one.
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real percentile
Histogram.iValue
(b, (long)Math.floor(r))Histogram.iPreciseValue
(b, r)array()
.bitsPerElement()
comments to this class
, section 3.
So, if μ is chosen less than the precision of this matrix β
(8 for byte, 16 for short, etc.), then BasicRankMorphology
object, μ is chosen while
instantiating this object
as percentile
in interface RankMorphology
src
 the source matrix.percentileIndexes
 the matrix containing r argument: the indexes of the percentile
for every element of the result.pattern
 the pattern: the shape of the aperture.RankMorphology.percentile(Matrix, double, Pattern)
,
RankMorphology.asPercentile(Matrix, Matrix, Pattern)
,
RankMorphology.percentile(Matrix, Matrix, Matrix, Pattern)
public Matrix<? extends UpdatablePArray> percentile(Matrix<? extends PArray> src, double percentileIndex, Pattern pattern)
RankMorphology
comments to this class
, section 4 about the "percentile" term.
The real index r of the percentile is equal to percentileIndex argument for
all aperture positions. The element type
of the created matrix is the same as the element type of the source one.
This method is equivalent to
percentile
(src, src.matrix(Arrays.nDoubleCopies
(src.size(), percentileIndex), pattern)
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real percentile
Histogram.iValue
(b, (long)Math.floor(r))Histogram.iPreciseValue
(b, r)array()
.bitsPerElement()
comments to this class
, section 3.
So, if μ is chosen less than the precision of this matrix β
(8 for byte, 16 for short, etc.), then BasicRankMorphology
object, μ is chosen while
instantiating this object
as percentile
in interface RankMorphology
src
 the source matrix.percentileIndex
 r argument of the percentile.pattern
 the pattern: the shape of the aperture.RankMorphology.percentile(Matrix, Matrix, Pattern)
,
RankMorphology.asPercentile(Matrix, double, Pattern)
,
RankMorphology.percentile(Matrix, Matrix, double, Pattern)
public <T extends PArray> Matrix<? extends T> rank(java.lang.Class<? extends T> requiredType, Matrix<? extends PArray> baseMatrix, Matrix<? extends PArray> rankedMatrix, Pattern pattern)
RankMorphology
comments to this class
, section 4 about the "rank" term.
The real value v for every element of the result is equal
to the corresponding element of rankedMatrix matrix.
The matrix, returned by this method, is updatable, and the class of its builtin array
implements one of the basic interfaces
UpdatableBitArray
, UpdatableCharArray
,
UpdatableByteArray
, UpdatableShortArray
,
UpdatableIntArray
, UpdatableLongArray
,
UpdatableFloatArray
or UpdatableDoubleArray
.
The class of desired interface (one of 8 possible classes) must be passed as requiredType argument.
So, it defines the element type of the returned matrix.
Instead of these classes, you can also pass one of corresponding immutable interfaces
BitArray
, CharArray
,
ByteArray
, ShortArray
,
IntArray
, LongArray
,
FloatArray
or DoubleArray
:
the result will be the same.
The rules of casting the floatingpoint ranks to the desired element type are the same as in
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
The element types of baseMatrix and rankedMatrix are usually equal.
If they are different (elementType()
!=rankedMatrix.elementType()
Matrices.asFuncMatrix
(true,Func.IDENTITY
, baseMatrix.array().type()
, rankedMatrix)
before all other calculations. In other words, this method always casts the type of
the ranked elements to the type of baseMatrix elements.
As a result, we can be sure, that if the source baseMatrix matrix is fixedpoint
(boolean, char, byte, short, int or long elements),
then the rank pointCount()
rank
in interface RankMorphology
requiredType
 the desired type of the builtin array in the returned matrix.baseMatrix
 the source matrix.rankedMatrix
 the matrix containing v argument: the values,
the rank of which should be calculated.pattern
 the pattern: the shape of the aperture.RankMorphology.asRank(Class, Matrix, Matrix, Pattern)
,
RankMorphology.rank(Matrix, Matrix, Matrix, Pattern)
public Matrix<? extends UpdatablePArray> meanBetweenPercentiles(Matrix<? extends PArray> src, Matrix<? extends PArray> fromPercentileIndexes, Matrix<? extends PArray> toPercentileIndexes, Pattern pattern, double filler)
RankMorphology
comments to this class
, section 4 about the
"mean between 2 percentiles" term.
The real indexes r_{1} and r_{2} of the percentiles
for every element of the result are equal to the corresponding elements of
fromPercentileIndexes and toPercentileIndexes matrices.
The reserved value filler is specified by the last argument of this method.
The element type
of the created matrix is the same as the element type of the source one.
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined in the comments to this class.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
meanBetweenPercentiles
in interface RankMorphology
src
 the source matrix.fromPercentileIndexes
 the matrix containing r_{1} argument: the indexes of
the less percentile of the averaged range for every element of the result.toPercentileIndexes
 the matrix containing r_{2} argument: the indexes of
the greater percentile of the averaged range for every element of the result.pattern
 the pattern: the shape of the aperture.filler
 the reserved value, returned when
RankMorphology.meanBetweenPercentiles(Matrix, double, double, Pattern, double)
,
RankMorphology.asMeanBetweenPercentiles(Matrix, Matrix, Matrix, Pattern, double)
,
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, Matrix, Matrix, Pattern, double)
public Matrix<? extends UpdatablePArray> meanBetweenPercentiles(Matrix<? extends PArray> src, double fromPercentileIndex, double toPercentileIndex, Pattern pattern, double filler)
RankMorphology
comments to this class
, section 4 about the
"mean between 2 percentiles" term.
The real indexes r_{1} and r_{2} of the percentiles
for every element of the result are equal to fromPercentileIndex
and toPercentileIndex arguments for all aperture positions.
The reserved value filler is specified by the last argument of this method.
The element type
of the created matrix is the same as the element type of the source one.
This method is equivalent to
meanBetweenPercentiles
(src, src.matrix(Arrays.nDoubleCopies
(src.size(), fromPercentileIndex), src.matrix(Arrays.nDoubleCopies
(src.size(), toPercentileIndex), pattern, filler)
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined in the comments to this class.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
meanBetweenPercentiles
in interface RankMorphology
src
 the source matrix.fromPercentileIndex
 r_{1} argument: the index of
the less percentile of the averaged range for every element of the result.toPercentileIndex
 r_{2} argument: the indexes of
the greater percentile of the averaged range for every element of the result.pattern
 the pattern: the shape of the aperture.filler
 the reserved value, returned when
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, Matrix, Pattern, double)
,
RankMorphology.asMeanBetweenPercentiles(Matrix, double, double, Pattern, double)
,
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, double, double, Pattern, double)
public Matrix<? extends UpdatablePArray> meanBetweenValues(Matrix<? extends PArray> src, Matrix<? extends PArray> minValues, Matrix<? extends PArray> maxValues, Pattern pattern, double filler)
RankMorphology
comments to this class
, section 4 about the
"mean between 2 values" term.
The real numbers v_{1} and v_{2}
for every element of the result are equal to the corresponding elements of
minValues and maxValues matrices.
The reserved value filler and the mode of calculation (for the case
RankMorphology.FILL_MIN_VALUE
(Double.NEGATIVE_INFINITY),
the mode B is used;RankMorphology.FILL_MAX_VALUE
(Double.POSITIVE_INFINITY),
the mode C is used;RankMorphology.FILL_NEAREST_VALUE
(Double.NaN),
the mode D is used;element type
of the created matrix is the same as the element type of the source one.
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined in the comments to this class.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
meanBetweenValues
in interface RankMorphology
src
 the source matrix.minValues
 the matrix containing v_{1} argument: the low bound
of the averaged range of values for every element of the result.maxValues
 the matrix containing v_{2} argument: the high bound
of the averaged range of values for every element of the result.pattern
 the pattern: the shape of the aperture.filler
 the reserved value, returned when
RankMorphology.FILL_MIN_VALUE
, RankMorphology.FILL_MAX_VALUE
,
RankMorphology.FILL_NEAREST_VALUE
, which mean using of special calculation modes B, C, D.RankMorphology.asMeanBetweenValues(Matrix, Matrix, Matrix, Pattern, double)
,
RankMorphology.meanBetweenValues(Matrix, Matrix, Matrix, Matrix, Pattern, double)
public Matrix<? extends UpdatablePArray> mean(Matrix<? extends PArray> src, Pattern pattern)
RankMorphology
More precisely, this method is equivalent to
functionOfSum
(src, pattern, meanFunc)
LinearFunc.getInstance
(0.0, 1.0/N),
pointCount()
elementType()
LinearFunc.getInstance
(0.5, 1.0/N),
pointCount()
elementType()
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined above.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
The described rounding rule explains, why we add 0.5 to the mean in the case of a fixedpoint source
elements. Namely, in this case the combination of adding 0.5 and further truncation to the integer part
works as rounding to the nearest integer:
Note: the behaviour of this method is similar to
meanBetweenPercentiles
(src, 0, N, pattern, anyFiller),
where pointCount()
comments to SummingHistogram class
).
Really, in this case the mean between 2 percentiles is equal to
(S(r_{2})−S(r_{1})) / ((r_{2}−r_{1})*σ) = S(N) / (N*σ) = (Σ _{0≤j<M}(j+0.5)*b[j]) / (N*σ)
In the simplest case, when the source elements are real numbers in the "standard" allowed range
(Σ _{0≤i<N}(a_{i}+0.5)) / (NM) = (v'_{0}+v'_{1}+...+v'_{N−1}) / N + 0.5 / M ≈ (v_{0}+v_{1}+...+v_{N−1}) / N
where
In another simplest case, when the source elements are integer numbers, σ=1 and
the elements v_{i} are nonnegative integers,
we have
(Σ _{0≤i<N}(v_{i}+0.5)) / N = (v_{0}+v_{1}+...+v_{N−1}) / N + 0.5
mean
in interface RankMorphology
src
 the source matrix.pattern
 the pattern: the shape of the aperture.RankMorphology.asMean(Matrix, Pattern)
,
RankMorphology.mean(Matrix, Matrix, Pattern)
public Matrix<? extends UpdatablePArray> functionOfSum(Matrix<? extends PArray> src, Pattern pattern, Func processingFunc)
RankMorphology
comments to this class
, section 4 about the
"aperture sum" term.
The element type
of the created matrix is the same as the element type of the source one.
The function, applied to each calculated aperture sum S, is specified via
processingFunc argument. Namely, for each aperture position this method
calculates the aperture sum S of the source matrix and returns
get
(S)
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real function result.
In this case, the found function result f is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
This method can be considered as a generalization of RankMorphology.mean(Matrix, Pattern)
.
functionOfSum
in interface RankMorphology
src
 the source matrix.pattern
 the pattern: the shape of the aperture.processingFunc
 the function, which should be applied to every calculated aperture sum.RankMorphology.asFunctionOfSum(Matrix, Pattern, Func)
,
RankMorphology.functionOfSum(Matrix, Matrix, Pattern, Func)
public Matrix<? extends UpdatablePArray> functionOfPercentilePair(Matrix<? extends PArray> src, Matrix<? extends PArray> percentileIndexes1, Matrix<? extends PArray> percentileIndexes2, Pattern pattern, Func processingFunc)
RankMorphology
comments to this class
, 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 percentileIndexes1 (for v_{1})
or percentileIndexes2 matrix (for v_{2}).
The element type
of the created matrix is the same as the element type of the source one.
The function, applied to each calculated three
get
(v,v_{1},v_{2})
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real function result.
In this case, the found function result f is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
You can get the same results by 2 calls of RankMorphology.percentile(Matrix, Matrix, Pattern)
method
for both matrices of percentile indexes and applying the function to them and to the source matrix via
Matrices.asFuncMatrix(Func, Class, Matrix, Matrix, Matrix)
ContrastingFunc
object as processingFunc argument.
functionOfPercentilePair
in interface RankMorphology
src
 the source matrix.percentileIndexes1
 the 1st matrix containing r argument: the indexes of the 1st percentile
v_{1} for every element of the result.percentileIndexes2
 the 2nd matrix containing r argument: the indexes of the 2nd percentile
v_{2} for every element of the result.pattern
 the pattern: the shape of the aperture.processingFunc
 the function, which should be applied to every calculated three
RankMorphology.functionOfPercentilePair(Matrix, double, double, Pattern, Func)
,
RankMorphology.asFunctionOfPercentilePair(Matrix, Matrix, Matrix, Pattern, Func)
,
RankMorphology.functionOfPercentilePair(Matrix, Matrix, Matrix, Matrix, Pattern, Func)
public Matrix<? extends UpdatablePArray> functionOfPercentilePair(Matrix<? extends PArray> src, double percentileIndex1, double percentileIndex2, Pattern pattern, Func processingFunc)
RankMorphology
comments to this class
, section 4 about the "percentile" term.
The real indexes r of two percentiles for every element of the result are equal
to percentileIndex1 (for v_{1})
or percentileIndex2 argument (for v_{2}).
The element type
of the created matrix is the same as the element type of the source one.
This method is equivalent to
functionOfPercentilePair
(src, src.matrix(Arrays.nDoubleCopies
(src.size(), percentileIndex1), src.matrix(Arrays.nDoubleCopies
(src.size(), percentileIndex1), pattern, processingFunc)
If the element type of the source matrix (and, thus, of the result) is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real function result.
In this case, the found function result f is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
You can get the same results by 2 calls of RankMorphology.percentile(Matrix, double, Pattern)
method
for both matrices of percentile indexes and applying the function to them and to the source matrix via
Matrices.asFuncMatrix(Func, Class, Matrix, Matrix, Matrix)
ContrastingFunc
object as processingFunc argument.
functionOfPercentilePair
in interface RankMorphology
src
 the source matrix.percentileIndex1
 the 1st r argument: the index of the 1st percentile v_{1}.percentileIndex2
 the 2nd r argument: the index of the 2nd percentile v_{2}.pattern
 the pattern: the shape of the aperture.processingFunc
 the function, which should be applied to every calculated three
RankMorphology.functionOfPercentilePair(Matrix, Matrix, Matrix, Pattern, Func)
,
RankMorphology.asFunctionOfPercentilePair(Matrix, double, double, Pattern, Func)
,
RankMorphology.functionOfPercentilePair(Matrix, Matrix, double, double, Pattern, Func)
public void percentile(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, Matrix<? extends PArray> percentileIndexes, Pattern pattern)
RankMorphology
RankMorphology.percentile(Matrix, Matrix, Pattern)
method, but the result matrix
will be placed in the dest argument.
If the element type
of the passed dest matrix
is the same as the element type of the source one, the result, saved in dest, will be identically
equal to the result of RankMorphology.percentile(Matrix, Matrix, Pattern)
method with the same
src, percentileIndexes and pattern arguments. In other case,
the result, saved in dest, will be equal to
Matrices.asFuncMatrix
(true,Func.IDENTITY
, dest.array().type()
,percentile
(src, percentileIndexes, pattern))
So, even if the precision of dest matrix is better than the precision of src —
for example, if elementType()
elementType()
RankMorphology.asPercentile(Matrix, Matrix, Pattern)
RankMorphology.percentile(Matrix, Matrix, Pattern)
percentile
in interface RankMorphology
dest
 the target matrix.src
 the source matrix.percentileIndexes
 the matrix containing r argument: the indexes of the percentile
for every element of the result.pattern
 the pattern: the shape of the aperture.RankMorphology.percentile(Matrix, Matrix, double, Pattern)
,
RankMorphology.asPercentile(Matrix, Matrix, Pattern)
,
RankMorphology.percentile(Matrix, Matrix, Pattern)
public void percentile(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, double percentileIndex, Pattern pattern)
RankMorphology
RankMorphology.percentile(Matrix, double, Pattern)
method, but the result matrix
will be placed in the dest argument.
This method is equivalent to
percentile
(dest, src, src.matrix(Arrays.nDoubleCopies
(src.size(), percentileIndex), pattern)
percentile
in interface RankMorphology
dest
 the target matrix.src
 the source matrix.percentileIndex
 r argument of the percentile.pattern
 the pattern: the shape of the aperture.RankMorphology.percentile(Matrix, Matrix, Matrix, Pattern)
,
RankMorphology.asPercentile(Matrix, double, Pattern)
,
RankMorphology.percentile(Matrix, double, Pattern)
public void rank(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> baseMatrix, Matrix<? extends PArray> rankedMatrix, Pattern pattern)
RankMorphology
RankMorphology.rank(Class, Matrix, Matrix, Pattern)
method, but the result matrix
will be placed in the dest argument and the required type will be chosen automatically
as type
(PArray.class)rank
(dest.array().type()
, baseMatrix, rankedMatrix, pattern)
The element types of baseMatrix and rankedMatrix are usually equal.
If they are different (elementType()
!=rankedMatrix.elementType()
Matrices.asFuncMatrix
(true,Func.IDENTITY
, baseMatrix.array().type()
, rankedMatrix)
before all other calculations. In other words, this method always casts the type of
the ranked elements to the type of baseMatrix elements.
As a result, we can be sure, that if the source baseMatrix matrix is fixedpoint
(boolean, char, byte, short, int or long elements),
then the rank pointCount()
rank
in interface RankMorphology
dest
 the target matrix.baseMatrix
 the source matrix.rankedMatrix
 the matrix containing v argument: the values,
the rank of which should be calculated.pattern
 the pattern: the shape of the aperture.RankMorphology.asRank(Class, Matrix, Matrix, Pattern)
,
RankMorphology.rank(Class, Matrix, Matrix, Pattern)
public void meanBetweenPercentiles(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, Matrix<? extends PArray> fromPercentileIndexes, Matrix<? extends PArray> toPercentileIndexes, Pattern pattern, double filler)
RankMorphology
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, Matrix, Pattern, double)
method,
but the result matrix will be placed in the dest argument.
If the element type of dest matrix is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined in the comments to this class.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
meanBetweenPercentiles
in interface RankMorphology
dest
 the target matrix.src
 the source matrix.fromPercentileIndexes
 the matrix containing r_{1} argument: the indexes of
the less percentile of the averaged range for every element of the result.toPercentileIndexes
 the matrix containing r_{2} argument: the indexes of
the greater percentile of the averaged range for every element of the result.pattern
 the pattern: the shape of the aperture.filler
 the reserved value, returned when
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, double, double, Pattern, double)
,
RankMorphology.asMeanBetweenPercentiles(Matrix, Matrix, Matrix, Pattern, double)
,
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, Matrix, Pattern, double)
public void meanBetweenPercentiles(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, double fromPercentileIndex, double toPercentileIndex, Pattern pattern, double filler)
RankMorphology
RankMorphology.meanBetweenPercentiles(Matrix, double, double, Pattern, double)
method,
but the result matrix will be placed in the dest argument.
If the element type of dest matrix is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined in the comments to this class.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
meanBetweenPercentiles
in interface RankMorphology
dest
 the target matrix.src
 the source matrix.fromPercentileIndex
 r_{1} argument: the index of
the less percentile of the averaged range for every element of the result.toPercentileIndex
 r_{2} argument: the indexes of
the greater percentile of the averaged range for every element of the result.pattern
 the pattern: the shape of the aperture.filler
 the reserved value, returned when
RankMorphology.meanBetweenPercentiles(Matrix, Matrix, Matrix, Matrix, Pattern, double)
,
RankMorphology.asMeanBetweenPercentiles(Matrix, double, double, Pattern, double)
,
RankMorphology.meanBetweenPercentiles(Matrix, double, double, Pattern, double)
public void meanBetweenValues(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, Matrix<? extends PArray> minValues, Matrix<? extends PArray> maxValues, Pattern pattern, double filler)
RankMorphology
RankMorphology.meanBetweenValues(Matrix, Matrix, Matrix, Pattern, double)
method, but the result matrix
will be placed in the dest argument.
If the element type of dest matrix is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined in the comments to this class.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
meanBetweenValues
in interface RankMorphology
dest
 the target matrix.src
 the source matrix.minValues
 the matrix containing v_{1} argument: the low bound
of the averaged range of values for every element of the result.maxValues
 the matrix containing v_{2} argument: the high bound
of the averaged range of values for every element of the result.pattern
 the pattern: the shape of the aperture.filler
 the reserved value, returned when
RankMorphology.FILL_MIN_VALUE
, RankMorphology.FILL_MAX_VALUE
,
RankMorphology.FILL_NEAREST_VALUE
, which mean using of special calculation modes B, C, D.RankMorphology.asMeanBetweenValues(Matrix, Matrix, Matrix, Pattern, double)
,
RankMorphology.meanBetweenValues(Matrix, Matrix, Matrix, Pattern, double)
public void mean(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, Pattern pattern)
RankMorphology
RankMorphology.mean(Matrix, Pattern)
method,
but the result matrix will be placed in the dest argument.
If the element type of dest matrix is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real mean, defined above.
In this case, the found mean value m is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
The described rounding rule explains, why we add 0.5 to the mean in the case of a fixedpoint source
elements. Namely, in this case the combination of adding 0.5 and further truncation to the integer part
works as rounding to the nearest integer:
Note: the behaviour of this method is similar to
meanBetweenPercentiles
(src, 0, N, pattern, anyFiller),
where pointCount()
comments to SummingHistogram class
).
Really, in this case the mean between 2 percentiles is equal to
(S(r_{2})−S(r_{1})) / ((r_{2}−r_{1})*σ) = S(N) / (N*σ) = (Σ _{0≤j<M}(j+0.5)*b[j]) / (N*σ)
In the simplest case, when the source elements are real numbers in the "standard" allowed range
(Σ _{0≤i<N}(a_{i}+0.5)) / (NM) = (v'_{0}+v'_{1}+...+v'_{N−1}) / N + 0.5 / M ≈ (v_{0}+v_{1}+...+v_{N−1}) / N
where
In another simplest case, when the source elements are integer numbers, σ=1 and
the elements v_{i} are nonnegative integers,
we have
(Σ _{0≤i<N}(v_{i}+0.5)) / N = (v_{0}+v_{1}+...+v_{N−1}) / N + 0.5
mean
in interface RankMorphology
dest
 the target matrix.src
 the source matrix.pattern
 the pattern: the shape of the aperture.RankMorphology.asMean(Matrix, Pattern)
,
RankMorphology.mean(Matrix, Pattern)
public void functionOfSum(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, Pattern pattern, Func processingFunc)
RankMorphology
RankMorphology.functionOfSum(Matrix, Pattern, Func)
method,
but the result matrix will be placed in the dest argument.
If the element type of dest matrix is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real function result.
In this case, the found function result f is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
This method can be considered as a generalization of RankMorphology.mean(Matrix, Matrix, Pattern)
.
functionOfSum
in interface RankMorphology
dest
 the target matrix.src
 the source matrix.pattern
 the pattern: the shape of the aperture.processingFunc
 the function, which should be applied to every calculated aperture sum.RankMorphology.asFunctionOfSum(Matrix, Pattern, Func)
,
RankMorphology.functionOfSum(Matrix, Pattern, Func)
public void functionOfPercentilePair(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, Matrix<? extends PArray> percentileIndexes1, Matrix<? extends PArray> percentileIndexes2, Pattern pattern, Func processingFunc)
RankMorphology
RankMorphology.functionOfPercentilePair(Matrix, Matrix, Matrix, Pattern, Func)
method,
but the result matrix will be placed in the dest argument.
If the element type of dest matrix is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real function result.
In this case, the found function result f is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
functionOfPercentilePair
in interface RankMorphology
dest
 the target matrix.src
 the source matrix.percentileIndexes1
 the 1st matrix containing r argument: the indexes of the 1st percentile
v_{1} for every element of the result.percentileIndexes2
 the 2nd matrix containing r argument: the indexes of the 2nd percentile
v_{2} for every element of the result.pattern
 the pattern: the shape of the aperture.processingFunc
 the function, which should be applied to every calculated three
RankMorphology.functionOfPercentilePair(Matrix, Matrix, double, double, Pattern, Func)
,
RankMorphology.asFunctionOfPercentilePair(Matrix, Matrix, Matrix, Pattern, Func)
,
RankMorphology.functionOfPercentilePair(Matrix, Matrix, Matrix, Pattern, Func)
public void functionOfPercentilePair(Matrix<? extends UpdatablePArray> dest, Matrix<? extends PArray> src, double percentileIndex1, double percentileIndex2, Pattern pattern, Func processingFunc)
RankMorphology
RankMorphology.functionOfPercentilePair(Matrix, double, double, Pattern, Func)
method,
but the result matrix will be placed in the dest argument.
If the element type of dest matrix is fixedpoint —
boolean, char, byte, short, int or long —
then we need to round the real function result.
In this case, the found function result f is usually truncated to its integer part
Arrays.asFuncArray(boolean, Func, Class, PArray...)
method with the argument truncateOverflows=true.
functionOfPercentilePair
in interface RankMorphology
dest
 the target matrix.src
 the source matrix.percentileIndex1
 the 1st r argument: the index of the 1st percentile v_{1}.percentileIndex2
 the 2nd r argument: the index of the 2nd percentile v_{2}.pattern
 the pattern: the shape of the aperture.processingFunc
 the function, which should be applied to every calculated three
RankMorphology.functionOfPercentilePair(Matrix, Matrix, Matrix, Matrix, Pattern, Func)
,
RankMorphology.asFunctionOfPercentilePair(Matrix, double, double, Pattern, Func)
,
RankMorphology.functionOfPercentilePair(Matrix, double, double, Pattern, Func)