java.lang.Object
imagingbook.common.math.VectorNorm
- Direct Known Subclasses:
VectorNorm.L1,VectorNorm.L2,VectorNorm.Linf
This class defines various vector norms for calculating the magnitude of a vector and the distance between vectors.
- Version:
- 2022/09/11
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImplementation of the L1 vector norm (Manhattan norm/distance).static classImplementation of the L2 vector norm (Euclidean norm/distance).static classImplementation of the L-infinity vector norm (maximum norm/distance).static enumEnumeration type forVectorNormto be used as parameter choice. -
Method Summary
Modifier and TypeMethodDescriptionabstract doubledistance(double[] a, double[] b) Returns the distance between twodouble[]vectors under this norm.abstract doubledistance(float[] a, float[] b) Returns the distance between twofloat[]vectors under this norm.abstract doubledistance(int[] a, int[] b) Returns the distance between twoint[]vectors under this norm.abstract doubledistance2(double[] a, double[] b) Returns the squared distance between twodouble[]vectors under this norm.abstract doubledistance2(float[] a, float[] b) Returns the squared distance between twofloat[]vectors under this norm.abstract doubledistance2(int[] a, int[] b) Returns the squared distance between twoint[]vectors under this norm.abstract doublegetScale(int n) Returns a factor to scale magnitude and distance values to the range of the vector components of dimensionality n.abstract doublemagnitude(double[] a) Returns the magnitude of the specifieddouble[]vector under this norm.abstract doublemagnitude(float[] a) Returns the magnitude of the specifiedfloat[]vector under this norm.abstract doublemagnitude(int[] a) Returns the magnitude of the specifiedint[]vector under this norm.
-
Method Details
-
magnitude
Returns the magnitude of the specifieddouble[]vector under this norm.- Parameters:
a- a vector- Returns:
- the magnitude of the vector
-
magnitude
Returns the magnitude of the specifiedfloat[]vector under this norm.- Parameters:
a- a vector- Returns:
- the magnitude of the vector
-
magnitude
Returns the magnitude of the specifiedint[]vector under this norm.- Parameters:
a- a vector- Returns:
- the magnitude of the vector
-
distance
Returns the distance between twodouble[]vectors under this norm.- Parameters:
a- first vectorb- second vector- Returns:
- the distance between vectors a and b
-
distance
Returns the distance between twofloat[]vectors under this norm.- Parameters:
a- first vectorb- second vector- Returns:
- the distance between vectors a and b
-
distance
Returns the distance between twoint[]vectors under this norm.- Parameters:
a- first vectorb- second vector- Returns:
- the distance between vectors a and b
-
distance2
Returns the squared distance between twodouble[]vectors under this norm.- Parameters:
a- first vectorb- second vector- Returns:
- the distance between vectors a and b
-
distance2
Returns the squared distance between twofloat[]vectors under this norm.- Parameters:
a- first vectorb- second vector- Returns:
- the distance between vectors a and b
-
distance2
Returns the squared distance between twoint[]vectors under this norm.- Parameters:
a- first vectorb- second vector- Returns:
- the distance between vectors a and b
-
getScale
Returns a factor to scale magnitude and distance values to the range of the vector components of dimensionality n. This is prim. used for scaling color distances (n = 3). E.g., if components are distributed in [0,255], the distances multiplied by this factor should again be in [0,255].- Parameters:
n- dimensionality- Returns:
- scale factor
-