Class MinFromTwoSelectedNumbersFunc
- All Implemented Interfaces:
Func
Minimum from 2 arguments, selected by 1st argument:
f(x0, x1, ..., xn-1) =
min(xi+1, xj+1),
getInstance(int)
method.
More precisely, the get(double...)
method of this object performs the following actions:
int k1 = (int)x[0] + 1; // it is supposed that always 1<=(int)x[0]<=x.length int k2 = k1 + indexShift; if (k2 <= x.length) { // it is supposed that indexShift<x.length-1 k2 -= x.length - 1; } return x[k1] < x[k2] ? x[k1] : x[k2];
If k1 or k2 index, calculated in such a way, is out of range 0..x.length-1, this method throws IndexOutOfBoundsException.
This function can be useful for algorithms of non-maximum suppression, usually in combination with
Func.SELECT_FROM_8_DIRECTIONS_2D
, for example, in algorithms
like Canny edge detector.
This class is immutable and thread-safe: there are no ways to modify settings of the created instance.
- Author:
- Daniel Alievsky
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.algart.math.functions.Func
Func.Updatable
-
Field Summary
Fields inherited from interface net.algart.math.functions.Func
ABS, ABS_DIFF, HALF_X_MINUS_Y, HALF_X_PLUS_Y, HALF_Y_MINUS_X, IDENTITY, MAX, MIN, POSITIVE_DIFF, REVERSE, SELECT, SELECT_FROM_8_DIRECTIONS_2D, SELECT_IF_GREATER, SELECT_IF_GREATER_OR_EQUAL, SHIFTS_ALONG_8_DIRECTIONS_2D, UPDATABLE_IDENTITY, X_MINUS_Y, X_PLUS_Y, Y_MINUS_X
-
Method Summary
Modifier and TypeMethodDescriptiondouble
get
(double... x) Returns the result of this function for the given arguments: f(x0, x1, ..., xx.length-1).getInstance
(int indexShift) Returns an instance of this class for the given index shift.toString()
Returns a brief string description of this object.
-
Method Details
-
getInstance
Returns an instance of this class for the given index shift.- Parameters:
indexShift
- the index shift (distance between compared numbers); must be non-negative.- Returns:
- an instance of this class
- Throws:
IllegalArgumentException
- if indexShift<0.
-
get
public double get(double... x) Description copied from interface:Func
Returns the result of this function for the given arguments: f(x0, x1, ..., xx.length-1).This method must not change the values of x elements!
- Specified by:
get
in interfaceFunc
- Specified by:
get
in classAbstractFunc
- Parameters:
x
- the function arguments.- Returns:
- the function result.
-
toString
Returns a brief string description of this object.
-