Ocean
Ocean::LookupCorner2< T, TScalar > Class Template Reference

This class implements a 2D lookup object with values at the bins' corners defining the individual lookup values. More...

Inheritance diagram for Ocean::LookupCorner2< T, TScalar >:

Public Member Functions

 LookupCorner2 ()=default
 Creates a new empty lookup object. More...
 
 LookupCorner2 (const LookupCorner2< T, TScalar > &lookup)
 Copy constructor. More...
 
 LookupCorner2 (LookupCorner2< T, TScalar > &&lookup) noexcept
 Move constructor. More...
 
 LookupCorner2 (const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY)
 Creates a new lookup object by definition of the dimensions and bin numbers. More...
 
 LookupCorner2 (const size_t sizeX, const size_t sizeY, const size_t binsX, const size_t binsY, const T *binCornerValues)
 Creates a new lookup object by definition of the dimensions and bin numbers. More...
 
 LookupCorner2 (const size_t sizeX, const size_t sizeY, const LookupCorner2< T, TScalar > &lookup)
 Creates a new lookup object by definition of the dimensions and a given lookup object. More...
 
bool isInside (const TScalar x, const TScalar y) const
 Returns whether a given position lies inside this lookup object and therefore whether this position can be applied for the interpolation functions. More...
 
size_t binX (const TScalar x) const
 Returns the horizontal bin that corresponds to a precise horizontal lookup position. More...
 
size_t binY (const TScalar y) const
 Returns the vertical bin that corresponds to a precise vertical lookup position. More...
 
TScalar binTopLeftCornerPositionX (const size_t binX) const
 Returns the horizontal corner position of a specific bin corner (the top left corner) in relation to the dimension of this lookup object. More...
 
TScalar binTopLeftCornerPositionY (const size_t binY) const
 Returns the vertical corner position of a specific bin corner (the top left corner) in relation to the dimension of this lookup object. More...
 
Vector2 binTopLeftCornerPosition (const size_t binX, const size_t binY) const
 Returns the corner position (the top left corner) of a specific bin in relation to the dimension of this lookup object. More...
 
const T & binTopLeftCornerValue (const size_t binX, const size_t binY) const
 Returns the lookup value of a specific bin corner (the top left corner value) of this lookup object. More...
 
nearestValue (const TScalar x, const TScalar y) const
 Applies a lookup for a specific position in this lookup object. More...
 
bilinearValue (const TScalar x, const TScalar y) const
 Applies a lookup for a specific position in this lookup object. More...
 
template<typename TTarget = T>
void bilinearValues (const size_t y, TTarget *values) const
 Applies a lookup for an entire row in this lookup object. More...
 
template<typename TTarget = T>
void bilinearValues (const size_t x, const size_t y, const size_t size, TTarget *values) const
 Applies a lookup for a subset of a row in this lookup object. More...
 
void bilinearValue (const TScalar x, const TScalar y, T &topLeft, T &topRight, T &bottomLeft, T &bottomRight, TScalar &factorTopLeft, TScalar &factorTopRight, TScalar &factorBottomLeft, TScalar &factorBottomRight) const
 Applies a lookup for a specific position in this lookup object but does not apply the bilinear interpolation, instead all necessary parameters will be returned. More...
 
bicubicValue (const TScalar x, const TScalar y) const
 Applies a lookup for a specific position in this lookup object. More...
 
clampedNearestValue (const TScalar x, const TScalar y) const
 Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table. More...
 
clampedBilinearValue (const TScalar x, const TScalar y) const
 Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table. More...
 
clampedBicubicValue (const TScalar x, const TScalar y) const
 Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table. More...
 
void setBinTopLeftCornerValue (const size_t binX, const size_t binY, const T &value)
 Sets the value of one specific lookup bin's top left corner. More...
 
LookupCorner2< T, TScalar > operator+ (const T &offset) const
 Adds an offset value to each lookup value. More...
 
LookupCorner2< T, TScalar > & operator+= (const T &offset)
 Adds an offset value to each lookup value. More...
 
LookupCorner2< T, TScalar > operator- (const T &offset) const
 Subtracts an offset value from each lookup value. More...
 
LookupCorner2< T, TScalar > & operator-= (const T &offset)
 Subtracts an offset value from each lookup value. More...
 
LookupCorner2< T, TScalar > & operator= (const LookupCorner2< T, TScalar > &lookup)
 Copy operator. More...
 
LookupCorner2< T, TScalar > & operator= (LookupCorner2< T, TScalar > &&lookup) noexcept
 Move operator. More...
 
- Public Member Functions inherited from Ocean::Lookup2< T, Scalar >
const T * data () const
 Returns a pointer to the constant bin data (row aligned). More...
 
T * data ()
 Returns a pointer to the bin data (row aligned). More...
 
size_t sizeX () const
 Returns the horizontal dimension of this lookup object. More...
 
size_t sizeY () const
 Returns the vertical dimension of this lookup object. More...
 
size_t binsX () const
 Returns the number of horizontal bins of this lookup object. More...
 
size_t binsY () const
 Returns the number of vertical bins of this lookup object. More...
 
bool isEmpty () const
 Returns whether this lookup object does not hold any lookup bin. More...
 
 operator bool () const
 Returns whether this lookup object holds at least one lookup bin. More...
 
bool operator== (const Lookup2< T, Scalar > &lookup) const
 Returns whether two lookup objects are identical. More...
 
bool operator!= (const Lookup2< T, Scalar > &lookup) const
 Returns whether two lookup objects are not identical. More...
 

Additional Inherited Members

- Public Types inherited from Ocean::Lookup2< T, Scalar >
typedef T Type
 Definition of the lookup data type. More...
 
- Protected Types inherited from Ocean::Lookup2< T, Scalar >
typedef std::vector< T > Values
 Definition of a vector holding lookup values. More...
 
- Protected Member Functions inherited from Ocean::Lookup2< T, Scalar >
 Lookup2 ()=default
 Creates a new empty lookup object. More...
 
 Lookup2 (const Lookup2< T, Scalar > &lookup)
 Copy constructor. More...
 
 Lookup2 (Lookup2< T, Scalar > &&lookup) noexcept
 Move constructor. More...
 
Lookup2< T, Scalar > & operator= (const Lookup2< T, Scalar > &lookup)
 Assign operator. More...
 
Lookup2< T, Scalar > & operator= (Lookup2< T, Scalar > &&lookup) noexcept
 Move operator. More...
 
- Protected Attributes inherited from Ocean::Lookup2< T, Scalar >
size_t sizeX_
 Horizontal dimension of this lookup object. More...
 
size_t sizeY_
 Vertical dimension of this lookup object. More...
 
size_t binsX_
 Number of horizontal bins. More...
 
size_t binsY_
 Number of vertical bins. More...
 
Scalar invSizeX_
 Inverse horizontal dimension of this lookup object. More...
 
Scalar invSizeY_
 Inverse vertical dimension of this lookup object. More...
 
Scalar invBinsX_
 Inverse number of horizontal bins. More...
 
Scalar invBinsY_
 Inverse number of vertical bins. More...
 
Values values_
 The values of the lookup bins. More...
 

Detailed Description

template<typename T, typename TScalar = Scalar>
class Ocean::LookupCorner2< T, TScalar >

This class implements a 2D lookup object with values at the bins' corners defining the individual lookup values.

This area is separated into individual neighboring bins (with absolute identical sizes) as each bin may cover a non-integer sized area of elements (e.g, pixels).
Thus, the positions and sizes of a bin do not match with physical elements (e.g., pixels).

The lookup table with 4x2 bins has the following layout:

+ --- + --- + --- + --- +
|     |     |     |     |
+ --- + --- + --- + --- +
|     |     |     |     |
+ --- + --- + --- + --- +

With '+' showing the corner positions of the lookup values.
Thus, the lookup table has 4 horizontal bins and 5 horizontal lookup values.
The first lookup value is located at the horizontal position 0 and the last lookup value is located at the horizontal position sizeX (and not sizeX - 1).
The vertical positions are accordingly.

If this lookup table is applied to visual content like e.g. an image, the layout of a 4x2 bins object can be interpreted as follows:

 -----------------------
|+     +     +     +    |+
|                       |
|+     +     +     +    |+
|                       |
 -----------------------
 +     +     +     +     +

With '-' and '|' showing the border of the image (not covering one pixel).
Thus, the first column of lookup values is located in the image column with index '0' while the last column of lookup values is located in the image column with index 'width' (not width - 1).
And the first row of lookup values is located in the image row with index '0' while the last row of lookup values it located in the image row with index 'height' (not height - 1).

Template Parameters
TThe data type of the stored lookup values
TScalarThe data type of the scalar values, either 'float' or 'double'
See also
LookupCenter2

Constructor & Destructor Documentation

◆ LookupCorner2() [1/6]

template<typename T , typename TScalar = Scalar>
Ocean::LookupCorner2< T, TScalar >::LookupCorner2 ( )
default

Creates a new empty lookup object.

◆ LookupCorner2() [2/6]

template<typename T , typename TScalar >
Ocean::LookupCorner2< T, TScalar >::LookupCorner2 ( const LookupCorner2< T, TScalar > &  lookup)
inline

Copy constructor.

Parameters
lookupThe lookup object to be copied

◆ LookupCorner2() [3/6]

template<typename T , typename TScalar >
Ocean::LookupCorner2< T, TScalar >::LookupCorner2 ( LookupCorner2< T, TScalar > &&  lookup)
inlinenoexcept

Move constructor.

Parameters
lookupThe lookup object to be moved

◆ LookupCorner2() [4/6]

template<typename T , typename TScalar >
Ocean::LookupCorner2< T, TScalar >::LookupCorner2 ( const size_t  sizeX,
const size_t  sizeY,
const size_t  binsX,
const size_t  binsY 
)

Creates a new lookup object by definition of the dimensions and bin numbers.

Beware: The bin values will be initialized with the default constructor of the template class.

Parameters
sizeXHorizontal dimension of the lookup table, with range [1, infinity)
sizeYVertical dimension of the lookup table, with range [1, infinity)
binsXNumber of horizontal bins, with range [1, sizeX]
binsYNumber of vertical bins, with range [1, sizeY]

◆ LookupCorner2() [5/6]

template<typename T , typename TScalar >
Ocean::LookupCorner2< T, TScalar >::LookupCorner2 ( const size_t  sizeX,
const size_t  sizeY,
const size_t  binsX,
const size_t  binsY,
const T *  binCornerValues 
)

Creates a new lookup object by definition of the dimensions and bin numbers.

Parameters
sizeXHorizontal dimension of the lookup table, with range [1, infinity)
sizeYVertical dimension of the lookup table, with range [1, infinity)
binsXNumber of horizontal bins, with range [1, sizeX]
binsYNumber of vertical bins, with range [1, sizeY]
binCornerValuesThe bins' corner values of the lookup object (row aligned), (binsX + 1) * (binsY + 1) values must be provided

◆ LookupCorner2() [6/6]

template<typename T , typename TScalar >
Ocean::LookupCorner2< T, TScalar >::LookupCorner2 ( const size_t  sizeX,
const size_t  sizeY,
const LookupCorner2< T, TScalar > &  lookup 
)

Creates a new lookup object by definition of the dimensions and a given lookup object.

Parameters
sizeXHorizontal dimension of the lookup table, with range [1, infinity)
sizeYVertical dimension of the lookup table, with range [1, infinity)
lookupThe lookup object specifying the lookup values and the number of lookup bins

Member Function Documentation

◆ bicubicValue()

template<typename T , typename TScalar >
T Ocean::LookupCorner2< T, TScalar >::bicubicValue ( const TScalar  x,
const TScalar  y 
) const

Applies a lookup for a specific position in this lookup object.

The resulting value is cubic interpolated within the 16-neighborhood of the lookup bins.

Parameters
xPrecise horizontal position for the resulting lookup value, with range [0, sizeX()]
yPrecise vertical position for the resulting lookup value, with range [0, sizeY()]
Returns
The bi-cubic interpolated lookup value
See also
nearestValue(), bilinearValue(), clampedBicubicValue().

◆ bilinearValue() [1/2]

template<typename T , typename TScalar >
T Ocean::LookupCorner2< T, TScalar >::bilinearValue ( const TScalar  x,
const TScalar  y 
) const

Applies a lookup for a specific position in this lookup object.

The resulting value is bilinear interpolated within the 4-neighborhood of the lookup bins.

Parameters
xPrecise horizontal position for the resulting lookup value, with range [0, sizeX()]
yPrecise vertical position for the resulting lookup value, with range [0, sizeY()]
Returns
The bilinear interpolated lookup value
See also
nearestValue(), bicubicValue(), clampedBilinearValue(), bilinearValues().

◆ bilinearValue() [2/2]

template<typename T , typename TScalar >
void Ocean::LookupCorner2< T, TScalar >::bilinearValue ( const TScalar  x,
const TScalar  y,
T &  topLeft,
T &  topRight,
T &  bottomLeft,
T &  bottomRight,
TScalar &  factorTopLeft,
TScalar &  factorTopRight,
TScalar &  factorBottomLeft,
TScalar &  factorBottomRight 
) const

Applies a lookup for a specific position in this lookup object but does not apply the bilinear interpolation, instead all necessary parameters will be returned.

The resulting value is bilinear interpolated within the 4-neighborhood of the lookup bins.

Parameters
xPrecise horizontal position for the resulting lookup value, with range [0, sizeX()]
yPrecise vertical position for the resulting lookup value, with range [0, sizeY()]
topLeftThe lookup value of the top left bin (in relation to the lookup position)
topRightThe lookup value of the top right bin (in relation to the lookup position)
bottomLeftThe lookup value of the bottom left bin (in relation to the lookup position)
bottomRightThe lookup value of the bottom right bin (in relation to the lookup position)
factorTopLeftThe interpolation value for value of the top left bin, with range [0, 1]
factorTopRightThe interpolation value for value of the top right bin, with range [0, 1]
factorBottomLeftThe interpolation value for value of the bottom left bin, with range [0, 1]
factorBottomRightThe interpolation value for value of the bottom right bin, with range [0, 1]
See also
nearestValue(), bicubicValue(), clampedBilinearValue().

◆ bilinearValues() [1/2]

template<typename T , typename TScalar >
template<typename TTarget >
void Ocean::LookupCorner2< T, TScalar >::bilinearValues ( const size_t  x,
const size_t  y,
const size_t  size,
TTarget *  values 
) const

Applies a lookup for a subset of a row in this lookup object.

The resulting values are bilinear interpolated within the individual 4-neighborhood of the lookup bins. This function provides the same results as bilinearValue(), but for a subset of the row to speed up the computation.

Parameters
xThe horizontal start position for which the lookup values will be determined, with range [0, sizeX() - 1]
yThe vertical position of the row for which the lookup values will be determined, with range [0, sizeY() - 1]
sizeThe number of subsequent lookup values which will be created, with range [1, sizeX() - xStart]
valuesThe resulting size lookup values
Template Parameters
TTargetThe data type of the interpolated target values, e.g., T == VectorD2, TTarget == VectorF2
See also
bilinearValue().

◆ bilinearValues() [2/2]

template<typename T , typename TScalar >
template<typename TTarget >
void Ocean::LookupCorner2< T, TScalar >::bilinearValues ( const size_t  y,
TTarget *  values 
) const

Applies a lookup for an entire row in this lookup object.

The resulting values are bilinear interpolated within the individual 4-neighborhood of the lookup bins. This function provides the same results as bilinearValue(), but for an entire row to speed up the computation.

Parameters
yThe vertical position of the row for which the lookup values will be determined, with range [0, sizeY())
valuesThe resulting sizeX() lookup values
Template Parameters
TTargetThe data type of the interpolated target values, e.g., T == VectorD2, TTarget == VectorF2
See also
bilinearValue().

◆ binTopLeftCornerPosition()

template<typename T , typename TScalar >
Vector2 Ocean::LookupCorner2< T, TScalar >::binTopLeftCornerPosition ( const size_t  binX,
const size_t  binY 
) const
inline

Returns the corner position (the top left corner) of a specific bin in relation to the dimension of this lookup object.

Parameters
binXHorizontal bin position, with range [0, binsX()]
binYVertical bin position, with range [0, binsY()]
Returns
Precise position of the specified bin in relation to the lookup object's dimension, with range [0, sizeX()]x[0, sizeY()]

◆ binTopLeftCornerPositionX()

template<typename T , typename TScalar >
TScalar Ocean::LookupCorner2< T, TScalar >::binTopLeftCornerPositionX ( const size_t  binX) const
inline

Returns the horizontal corner position of a specific bin corner (the top left corner) in relation to the dimension of this lookup object.

Parameters
binXHorizontal bin position, with range [0, binsX()]
Returns
Precise horizontal position of the specified bin in relation to the lookup object's dimension, with range [0, sizeX()]

◆ binTopLeftCornerPositionY()

template<typename T , typename TScalar >
TScalar Ocean::LookupCorner2< T, TScalar >::binTopLeftCornerPositionY ( const size_t  binY) const
inline

Returns the vertical corner position of a specific bin corner (the top left corner) in relation to the dimension of this lookup object.

Parameters
binYVertical bin position, with range [0, binsY()]
Returns
Precise vertical position of the specified bin in relation to the lookup object's dimension, with range [0, sizeY()]

◆ binTopLeftCornerValue()

template<typename T , typename TScalar >
const T & Ocean::LookupCorner2< T, TScalar >::binTopLeftCornerValue ( const size_t  binX,
const size_t  binY 
) const
inline

Returns the lookup value of a specific bin corner (the top left corner value) of this lookup object.

Parameters
binXHorizontal bin position, with range [0, binsX()]
binYVertical bin position, with range [0, binsY()]
Returns
Bin lookup value

◆ binX()

template<typename T , typename TScalar >
size_t Ocean::LookupCorner2< T, TScalar >::binX ( const TScalar  x) const
inline

Returns the horizontal bin that corresponds to a precise horizontal lookup position.

Parameters
xPrecise horizontal position in relation to the dimension of this lookup object, with range [0, sizeX()]
Returns
Resulting horizontal bin index

◆ binY()

template<typename T , typename TScalar >
size_t Ocean::LookupCorner2< T, TScalar >::binY ( const TScalar  y) const
inline

Returns the vertical bin that corresponds to a precise vertical lookup position.

Parameters
yPrecise vertical position in relation to the dimension of this lookup object, with range [0, sizeY()]
Returns
Resulting vertical bin index

◆ clampedBicubicValue()

template<typename T , typename TScalar >
T Ocean::LookupCorner2< T, TScalar >::clampedBicubicValue ( const TScalar  x,
const TScalar  y 
) const

Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table.

The resulting value is cubic interpolated within the 16-neighborhood of the lookup bins.

Parameters
xPrecise horizontal position for the resulting lookup value, with range -(infinity, infinity)
yPrecise vertical position for the resulting lookup value, with range -(infinity, infinity)
Returns
The bi-cubic interpolated lookup value
See also
clampedNearestValue(), clampedBilinearValue(), bicubicValue().

◆ clampedBilinearValue()

template<typename T , typename TScalar >
T Ocean::LookupCorner2< T, TScalar >::clampedBilinearValue ( const TScalar  x,
const TScalar  y 
) const

Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table.

The resulting value is bilinear interpolated within the 4-neighborhood of the lookup bins.

Parameters
xPrecise horizontal position for the resulting lookup value, with range -(infinity, infinity)
yPrecise vertical position for the resulting lookup value, with range -(infinity, infinity)
Returns
The bilinear interpolated lookup value
See also
clampedNearestValue(), clampedBicubicValue(), bilinearValue().

◆ clampedNearestValue()

template<typename T , typename TScalar >
T Ocean::LookupCorner2< T, TScalar >::clampedNearestValue ( const TScalar  x,
const TScalar  y 
) const

Applies a lookup for a specific position in this lookup object while the position is clamped to match into the domain of the lookup table.

The resulting value is specified by the nearest bin (determined by the bin's corner positions).

Parameters
xPrecise horizontal position for the resulting lookup value, with range -(infinity, infinity)
yPrecise vertical position for the resulting lookup value, with range -(infinity, infinity)
Returns
The nearest lookup value
See also
clampedBilinearValue(), clampedBicubicValue(), nearestValue().

◆ isInside()

template<typename T , typename TScalar >
bool Ocean::LookupCorner2< T, TScalar >::isInside ( const TScalar  x,
const TScalar  y 
) const
inline

Returns whether a given position lies inside this lookup object and therefore whether this position can be applied for the interpolation functions.

Parameters
xPrecise horizontal position for the resulting lookup value, with range (-infinity, infinity)
yPrecise vertical position for the resulting lookup value, with range (-infinity, infinity)
Returns
True, if x and y is in the range [0, sizeX()]x[0, sizeY()]

◆ nearestValue()

template<typename T , typename TScalar >
T Ocean::LookupCorner2< T, TScalar >::nearestValue ( const TScalar  x,
const TScalar  y 
) const

Applies a lookup for a specific position in this lookup object.

The resulting value is specified by the nearest bin (determined by the bin's corner positions).

Parameters
xPrecise horizontal position for the resulting lookup value, with range [0, sizeX()]
yPrecise vertical position for the resulting lookup value, with range [0, sizeY()]
Returns
The nearest lookup value
See also
bilinearValue(), bicubicValue(), clampedNearestValue().

◆ operator+()

template<typename T , typename TScalar >
LookupCorner2< T, TScalar > Ocean::LookupCorner2< T, TScalar >::operator+ ( const T &  offset) const

Adds an offset value to each lookup value.

Parameters
offsetThe offset to be added
Returns
The new lookup object with shifted lookup values.

◆ operator+=()

template<typename T , typename TScalar >
LookupCorner2< T, TScalar > & Ocean::LookupCorner2< T, TScalar >::operator+= ( const T &  offset)

Adds an offset value to each lookup value.

Parameters
offsetThe offset to be added
Returns
The reference to this shifted lookup object

◆ operator-()

template<typename T , typename TScalar >
LookupCorner2< T, TScalar > Ocean::LookupCorner2< T, TScalar >::operator- ( const T &  offset) const

Subtracts an offset value from each lookup value.

Parameters
offsetThe offset to be subtracted
Returns
The new lookup object with shifted lookup values.

◆ operator-=()

template<typename T , typename TScalar >
LookupCorner2< T, TScalar > & Ocean::LookupCorner2< T, TScalar >::operator-= ( const T &  offset)

Subtracts an offset value from each lookup value.

Parameters
offsetThe offset to be subtracted
Returns
The reference to this shifted lookup object

◆ operator=() [1/2]

template<typename T , typename TScalar >
LookupCorner2< T, TScalar > & Ocean::LookupCorner2< T, TScalar >::operator= ( const LookupCorner2< T, TScalar > &  lookup)
inline

Copy operator.

Parameters
lookupThe lookup object to be copied
Returns
Reference to this object

◆ operator=() [2/2]

template<typename T , typename TScalar >
LookupCorner2< T, TScalar > & Ocean::LookupCorner2< T, TScalar >::operator= ( LookupCorner2< T, TScalar > &&  lookup)
inlinenoexcept

Move operator.

Parameters
lookupThe lookup object to be moved
Returns
Reference to this object

◆ setBinTopLeftCornerValue()

template<typename T , typename TScalar >
void Ocean::LookupCorner2< T, TScalar >::setBinTopLeftCornerValue ( const size_t  binX,
const size_t  binY,
const T &  value 
)
inline

Sets the value of one specific lookup bin's top left corner.

Parameters
binXHorizontal bin position, with range [0, binsX()]
binYVertical bin position, with range [0, binsY()]
valueThe value to be set

The documentation for this class was generated from the following file: