Loading...
Searching...
No Matches
casacore::Interpolate2D Class Reference
scimath package (libcasa_scimath) » Mathematics_module

More...

`#include <Interpolate2D.h>`

## Public Types

enum | Method { NEAREST , LINEAR , CUBIC , LANCZOS }

## Public Member Functions

| Interpolate2D (Interpolate2D::Method method=Interpolate2D::LINEAR)
| Constructor.
| Interpolate2D (const Interpolate2D &other)
| Copy constructor (copy semantics).
| ~Interpolate2D ()
| destructor
Interpolate2D & | operator= (const Interpolate2D &other)
| Assignment operator (copy semantics).
Bool | interp (Float &result, const Vector< Double > &where, const Matrix< Float > &data) const
| Do one Float interpolation, supply Matrix and mask (True is good), and pixel coordinate.
Bool | interp (Float &result, const Vector< Double > &where, const Matrix< Float > &data, const Matrix< Bool > &mask) const
Bool | interp (Double &result, const Vector< Double > &where, const Matrix< Double > &data) const
| Do one Double interpolation, supply Matrix/Array and mask (True is good), and pixel coordinate.
Bool | interp (Double &result, const Vector< Double > &where, const Matrix< Double > &data, const Matrix< Bool > &mask) const
Bool | interp (Complex &result, const Vector< Double > &where, const Matrix< Complex > &data) const
| Do one Complex interpolation, supply Matrix/Array and mask (True is good), and pixel coordinate.
Bool | interp (Complex &result, const Vector< Double > &where, const Matrix< Complex > &data, const Matrix< Bool > &mask) const
Bool | interp (DComplex &result, const Vector< Double > &where, const Matrix< DComplex > &data) const
| Do one DComplex interpolation, supply Matrix/Array and mask (True is good), and pixel coordinate.
Bool | interp (DComplex &result, const Vector< Double > &where, const Matrix< DComplex > &data, const Matrix< Bool > &mask) const
Bool | interp (Double &resultI, Double &resultJ, const Vector< Double > &where, const Matrix< Double > &dataI, const Matrix< Double > &dataJ, const Matrix< Bool > &mask) const
| Do two linear interpolations simultaneously.
template<typename T>
Bool | interpLinear2 (T &resultI, T &resultJ, const Vector< Double > &where, const Matrix< T > &dataI, const Matrix< T > &dataJ, const Matrix< Bool > &mask) const
Bool | interp (Bool &result, const Vector< Double > &where, const Matrix< Bool > &data) const
| Do one interpolation, supply boolean Matrix (True is good), and pixel coordinate.

## Static Public Member Functions

static Interpolate2D::Method | stringToMethod (const String &method)
| Convert string ("nearest", "linear", "cubic", "lanczos") to interpolation method.

## Private Types

typedef Bool(Interpolate2D::* | FuncPtrFloat) (Float &result, const Vector< Double > &where, const Matrix< Float > &data, const Matrix< Bool > *&maskPtr) const
| Typedefs for function pointers.
typedef Bool(Interpolate2D::* | FuncPtrDouble) (Double &result, const Vector< Double > &where, const Matrix< Double > &data, const Matrix< Bool > *&maskPtr) const
typedef Bool(Interpolate2D::* | FuncPtrBool) (Bool &result, const Vector< Double > &where, const Matrix< Bool > &data) const

## Private Member Functions

Bool | anyBadMaskPixels (const Matrix< Bool > *&mask, Int i1, Int i2, Int j1, Int j2) const
| Are any of the mask pixels bad ?
template<typename T>
Bool | interpNearest (T &result, const Vector< Double > &where, const Matrix< T > &data, const Matrix< Bool > *&maskPtr) const
| nearest neighbour interpolation
Bool | interpNearestBool (Bool &result, const Vector< Double > &where, const Matrix< Bool > &data) const
template<typename T>
Bool | interpLinear (T &result, const Vector< Double > &where, const Matrix< T > &data, const Matrix< Bool > *&maskPtr) const
| bi-linear interpolation
Bool | interpLinearBool (Bool &result, const Vector< Double > &where, const Matrix< Bool > &data) const
template<typename T>
Bool | interpCubic (T &result, const Vector< Double > &where, const Matrix< T > &data, const Matrix< Bool > *&maskPtr) const
| bi-cubic interpolation
Bool | interpCubicBool (Bool &result, const Vector< Double > &where, const Matrix< Bool > &data) const
template<typename T>
Bool | interpLanczos (T &result, const Vector< Double > &where, const Matrix< T > &data, const Matrix< Bool > *&maskPtr) const
| Lanczos interpolation.
Bool | interpLanczosBool (Bool &result, const Vector< Double > &where, const Matrix< Bool > &data) const
template<typename T>
T | sinc (const T x) const
| Lanczos interpolation: helper functions.
template<typename T>
T | L (const T x, const Int a) const
void | bcucof (Double c[4][4], const Double y[4], const Double y1[4], const Double y2[4], const Double y12[4]) const
| helping routine from numerical recipes

## Private Attributes

FuncPtrFloat | itsFuncPtrFloat
FuncPtrDouble | itsFuncPtrDouble
FuncPtrBool | itsFuncPtrBool

## Detailed Description

A two dimension interpolator for Matrices or Arrays

### Intended use:

Public interface

### Review Status

Reviewed By:
  wbrouw
Date Reviewed:
  2004/05/26

### Prerequisite

- Arrays

### Etymology

This class is called Interpolate2D because it does 2 dimensional interpolations

### Synopsis

Given a regular Array or Matrix and a vector of pixel coordinates, interpolate the values of that array/matrix onto those pixel coordinates.

Absolutely no checking of the consistency of the input data is done in order to preserve maximum speed. The coordinate vector must* have at least 2 elements (others will be ignored). If you supply data and mask, those arrays must be the same shape. Failure to follow these rules will result in your program crashing.

### Example

Matrix<Float> matt(10,10);
Vector<Double> where(2);
where(0) = 3.452; where(1) = 6.1;
Interpolate2D myInterp(Interpolate2D::LINEAR);
Float result;
Bool ok = myInterp.interp(result, where, matt);
casacore::Interpolate2D::Interpolate2D
Interpolate2D(Interpolate2D::Method method=Interpolate2D::LINEAR)
Constructor.
casacore::Interpolate2D::LINEAR
@ LINEAR
Bilinear.
Definition Interpolate2D.h:103
casacore::Matrix
Definition Matrix.h:87
casacore::Vector
Definition Vector.h:82
casacore::Float
float Float
Definition aipstype.h:52
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40

### Motivation

2-D interpolation is required in geometry transformation routines such as in ImageRegrid.

### To Do

- Alternative approach: instantiate with an Array, take a block of vector locations, return a block of interpolation results

Definition at line 94 of file Interpolate2D.h.

## Member Typedef Documentation

## FuncPtrBool

typedef Bool(Interpolate2D::* casacore::Interpolate2D::FuncPtrBool) (Bool &result, const Vector< Double > &where, const Matrix< Bool > &data) const

private

Definition at line 267 of file Interpolate2D.h.

## FuncPtrDouble

typedef Bool(Interpolate2D::* casacore::Interpolate2D::FuncPtrDouble) (Double &result, const Vector< Double > &where, const Matrix< Double > &data, const Matrix< Bool > *&maskPtr) const

private

Definition at line 262 of file Interpolate2D.h.

## FuncPtrFloat

typedef Bool(Interpolate2D::* casacore::Interpolate2D::FuncPtrFloat) (Float &result, const Vector< Double > &where, const Matrix< Float > &data, const Matrix< Bool > *&maskPtr) const

private

Typedefs for function pointers.

Definition at line 257 of file Interpolate2D.h.

## Member Enumeration Documentation

## Method

enum casacore::Interpolate2D::Method

Enumerator
NEAREST | Nearest neighbour.
LINEAR | Bilinear.
CUBIC | Bicubic.
LANCZOS | Lanczos.

Definition at line 97 of file Interpolate2D.h.

## Constructor & Destructor Documentation

## Interpolate2D() [1/2]

casacore::Interpolate2D::Interpolate2D | ( | Interpolate2D::Method | method = Interpolate2D::LINEAR | ) |

Constructor.

References LINEAR.

Referenced by Interpolate2D(), and operator=().

## Interpolate2D() [2/2]

casacore::Interpolate2D::Interpolate2D | ( | const Interpolate2D & | other | ) |

Copy constructor (copy semantics).

References Interpolate2D().

## ~Interpolate2D()

casacore::Interpolate2D::~Interpolate2D | ( |  | ) |

destructor

## Member Function Documentation

## anyBadMaskPixels()

Bool casacore::Interpolate2D::anyBadMaskPixels | ( | const Matrix< Bool > *& | mask,
|  | Int | i1,
|  | Int | i2,
|  | Int | j1,
|  | Int | j2 ) const

private

Are any of the mask pixels bad ?

Returns False if no mask.

References casacore::mask().

## bcucof()

void casacore::Interpolate2D::bcucof | ( | Double | c[4][4],
|  | const Double | y[4],
|  | const Double | y1[4],
|  | const Double | y2[4],
|  | const Double | y12[4] ) const

private

helping routine from numerical recipes

## interp() [1/10]

Bool casacore::Interpolate2D::interp | ( | Bool & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Bool > & | data ) const

Do one interpolation, supply boolean Matrix (True is good), and pixel coordinate.

Returns False if coordinate out of range. The result is False if any data value in the interpolation grid are False (bad), else True. No shape integrity checking is done.

## interp() [2/10]

Bool casacore::Interpolate2D::interp | ( | Complex & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Complex > & | data ) const

Do one Complex interpolation, supply Matrix/Array and mask (True is good), and pixel coordinate.

Returns False if coordinate out of range or data are masked. No shape integrity checking is done (see above). The real and imaginary parts are treated independently (see CAS-11375).

## interp() [3/10]

Bool casacore::Interpolate2D::interp | ( | Complex & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Complex > & | data,
|  | const Matrix< Bool > & | mask ) const

References casacore::mask().

## interp() [4/10]

Bool casacore::Interpolate2D::interp | ( | DComplex & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< DComplex > & | data ) const

Do one DComplex interpolation, supply Matrix/Array and mask (True is good), and pixel coordinate.

Returns False if coordinate out of range or data are masked. No shape integrity checking is done (see above). The real and imaginary parts are treated independently (see CAS-11375).

## interp() [5/10]

Bool casacore::Interpolate2D::interp | ( | DComplex & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< DComplex > & | data,
|  | const Matrix< Bool > & | mask ) const

References casacore::mask().

## interp() [6/10]

Bool casacore::Interpolate2D::interp | ( | Double & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Double > & | data ) const

Do one Double interpolation, supply Matrix/Array and mask (True is good), and pixel coordinate.

Returns False if coordinate out of range or data are masked. No shape integrity checking is done (see above).

## interp() [7/10]

Bool casacore::Interpolate2D::interp | ( | Double & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Double > & | data,
|  | const Matrix< Bool > & | mask ) const

References casacore::mask().

## interp() [8/10]

Bool casacore::Interpolate2D::interp | ( | Double & | resultI,
|  | Double & | resultJ,
|  | const Vector< Double > & | where,
|  | const Matrix< Double > & | dataI,
|  | const Matrix< Double > & | dataJ,
|  | const Matrix< Bool > & | mask ) const

Do two linear interpolations simultaneously.

The second call is direct. The first call transfers to the second call. It is assumed that the structure (shape, steps) of the mask and data files are the same.

References casacore::mask().

## interp() [9/10]

Bool casacore::Interpolate2D::interp | ( | Float & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Float > & | data ) const

Do one Float interpolation, supply Matrix and mask (True is good), and pixel coordinate.

Returns False if coordinate out of range or data are masked. No shape integrity checking is done (see above).

## interp() [10/10]

Bool casacore::Interpolate2D::interp | ( | Float & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Float > & | data,
|  | const Matrix< Bool > & | mask ) const

References casacore::mask().

## interpCubic()

template<typename T>

Bool casacore::Interpolate2D::interpCubic | ( | T & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< T > & | data,
|  | const Matrix< Bool > *& | maskPtr ) const

private

bi-cubic interpolation

## interpCubicBool()

Bool casacore::Interpolate2D::interpCubicBool | ( | Bool & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Bool > & | data ) const

private

## interpLanczos()

template<typename T>

Bool casacore::Interpolate2D::interpLanczos | ( | T & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< T > & | data,
|  | const Matrix< Bool > *& | maskPtr ) const

private

Lanczos interpolation.

## interpLanczosBool()

Bool casacore::Interpolate2D::interpLanczosBool | ( | Bool & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Bool > & | data ) const

private

## interpLinear()

template<typename T>

Bool casacore::Interpolate2D::interpLinear | ( | T & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< T > & | data,
|  | const Matrix< Bool > *& | maskPtr ) const

private

bi-linear interpolation

## interpLinear2()

template<typename T>

Bool casacore::Interpolate2D::interpLinear2 | ( | T & | resultI,
|  | T & | resultJ,
|  | const Vector< Double > & | where,
|  | const Matrix< T > & | dataI,
|  | const Matrix< T > & | dataJ,
|  | const Matrix< Bool > & | mask ) const

References casacore::mask().

## interpLinearBool()

Bool casacore::Interpolate2D::interpLinearBool | ( | Bool & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Bool > & | data ) const

private

## interpNearest()

template<typename T>

Bool casacore::Interpolate2D::interpNearest | ( | T & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< T > & | data,
|  | const Matrix< Bool > *& | maskPtr ) const

private

nearest neighbour interpolation

## interpNearestBool()

Bool casacore::Interpolate2D::interpNearestBool | ( | Bool & | result,
|  | const Vector< Double > & | where,
|  | const Matrix< Bool > & | data ) const

private

## L()

template<typename T>

T casacore::Interpolate2D::L | ( | const T | x,
|  | const Int | a ) const

private

## operator=()

Interpolate2D & casacore::Interpolate2D::operator= | ( | const Interpolate2D & | other | ) |

Assignment operator (copy semantics).

References Interpolate2D().

## sinc()

template<typename T>

T casacore::Interpolate2D::sinc | ( | const T | x | ) | const

private

Lanczos interpolation: helper functions.

## stringToMethod()

Interpolate2D::Method casacore::Interpolate2D::stringToMethod | ( | const String & | method | ) |

static

Convert string ("nearest", "linear", "cubic", "lanczos") to interpolation method.

The match is case insensitive.

## Member Data Documentation

## itsFuncPtrBool

FuncPtrBool casacore::Interpolate2D::itsFuncPtrBool

private

Definition at line 274 of file Interpolate2D.h.

## itsFuncPtrDouble

FuncPtrDouble casacore::Interpolate2D::itsFuncPtrDouble

private

Definition at line 273 of file Interpolate2D.h.

## itsFuncPtrFloat

FuncPtrFloat casacore::Interpolate2D::itsFuncPtrFloat

private

Definition at line 272 of file Interpolate2D.h.

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

- scimath/Mathematics/Interpolate2D.h