casa
$Rev:20696$
|
A two dimension interpolator for Matrices or Arrays. More...
#include <Interpolate2D.h>
Public Types | |
enum | Method { NEAREST, LINEAR, CUBIC } |
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 (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. | |
Method | interpolationMethod () const |
Recover interpolation method. | |
Static Public Member Functions | |
static Interpolate2D::Method | stringToMethod (const String &method) |
Convert string ("nearest", "linear", "cubic") to interpolation method Minimum match will do. | |
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 ? Returns False if no mask. | |
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 |
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 | |
Interpolate2D::Method | itsMethod |
FuncPtrFloat | itsFuncPtrFloat |
FuncPtrDouble | itsFuncPtrDouble |
FuncPtrBool | itsFuncPtrBool |
A two dimension interpolator for Matrices or Arrays.
Public interface
This class is called Interpolate2D because it does 2 dimensional interpolations
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.
Matrix<Float> matt(10,10); Vector<Float> where(2); where(0) = 3.452; where(1) = 6.1; Interpolate2D myInterp(Interpolate2D::LINEAR); Float result; Bool ok = myInterp(result, where, matt);
2-D interpolation is required in geometry transformation routines such as in ImageRegrid.
Definition at line 99 of file Interpolate2D.h.
typedef Bool(Interpolate2D::* casa::Interpolate2D::FuncPtrBool)(Bool &result, const Vector< Double > &where, const Matrix< Bool > &data) const [private] |
Definition at line 232 of file Interpolate2D.h.
typedef Bool(Interpolate2D::* casa::Interpolate2D::FuncPtrDouble)(Double &result, const Vector< Double > &where, const Matrix< Double > &data, const Matrix< Bool > *&maskPtr) const [private] |
Definition at line 227 of file Interpolate2D.h.
typedef Bool(Interpolate2D::* casa::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 222 of file Interpolate2D.h.
Definition at line 102 of file Interpolate2D.h.
Constructor.
casa::Interpolate2D::Interpolate2D | ( | const Interpolate2D & | other | ) |
Copy constructor (copy semantics)
destructor
Bool casa::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.
void casa::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
Bool casa::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).
Bool casa::Interpolate2D::interp | ( | Float & | result, |
const Vector< Double > & | where, | ||
const Matrix< Float > & | data, | ||
const Matrix< Bool > & | mask | ||
) | const |
Bool casa::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).
Bool casa::Interpolate2D::interp | ( | Double & | result, |
const Vector< Double > & | where, | ||
const Matrix< Double > & | data, | ||
const Matrix< Bool > & | mask | ||
) | const |
Bool casa::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.
Bool casa::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.
Bool casa::Interpolate2D::interpCubic | ( | T & | result, |
const Vector< Double > & | where, | ||
const Matrix< T > & | data, | ||
const Matrix< Bool > *& | maskPtr | ||
) | const [private] |
bi-cubic interpolation
Bool casa::Interpolate2D::interpCubicBool | ( | Bool & | result, |
const Vector< Double > & | where, | ||
const Matrix< Bool > & | data | ||
) | const [private] |
Bool casa::Interpolate2D::interpLinear | ( | T & | result, |
const Vector< Double > & | where, | ||
const Matrix< T > & | data, | ||
const Matrix< Bool > *& | maskPtr | ||
) | const [private] |
bi-linear interpolation
Bool casa::Interpolate2D::interpLinear2 | ( | T & | resultI, |
T & | resultJ, | ||
const Vector< Double > & | where, | ||
const Matrix< T > & | dataI, | ||
const Matrix< T > & | dataJ, | ||
const Matrix< Bool > & | mask | ||
) | const |
Bool casa::Interpolate2D::interpLinearBool | ( | Bool & | result, |
const Vector< Double > & | where, | ||
const Matrix< Bool > & | data | ||
) | const [private] |
Bool casa::Interpolate2D::interpNearest | ( | T & | result, |
const Vector< Double > & | where, | ||
const Matrix< T > & | data, | ||
const Matrix< Bool > *& | maskPtr | ||
) | const [private] |
nearest neighbour interpolation
Bool casa::Interpolate2D::interpNearestBool | ( | Bool & | result, |
const Vector< Double > & | where, | ||
const Matrix< Bool > & | data | ||
) | const [private] |
Method casa::Interpolate2D::interpolationMethod | ( | ) | const [inline] |
Interpolate2D& casa::Interpolate2D::operator= | ( | const Interpolate2D & | other | ) |
Assignment operator (copy semantics)
static Interpolate2D::Method casa::Interpolate2D::stringToMethod | ( | const String & | method | ) | [static] |
Convert string ("nearest", "linear", "cubic") to interpolation method Minimum match will do.
Definition at line 238 of file Interpolate2D.h.
Definition at line 237 of file Interpolate2D.h.
Definition at line 236 of file Interpolate2D.h.
Definition at line 218 of file Interpolate2D.h.
Referenced by interpolationMethod().