mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Functions for transforming images by rotating, translating, and magnifying.
Classes | |
struct | mx::improc::bilinearTransform< _arithT > |
Transformation by bi-linear interpolation. More... | |
struct | mx::improc::cubicConvolTransform< _arithT > |
Transformation by cubic convolution interpolation. More... | |
Typedefs | |
typedef bilinearTransform< float > | mx::improc::bilinearTransf |
Typedef for bilinearTransform with single precision. More... | |
typedef bilinearTransform< double > | mx::improc::bilinearTransd |
Typedef for bilinearTransform with double precision. More... | |
typedef cubicConvolTransform< float > | mx::improc::cubicConvolTransf |
Typedef for cubicConvolTransform with single precision. More... | |
typedef cubicConvolTransform< double > | mx::improc::cubicConvolTransd |
Typedef for cubicConvolTransform with double precision. More... | |
template<typename transformT , typename arrT , typename arrT2 , typename floatT > | |
void | mx::improc::imageRotate (arrT &transim, const arrT2 &im, floatT dq, transformT trans) |
Rotate an image represented as an eigen array. More... | |
template<typename outputArrT , typename inputArrT > | |
void | mx::improc::imageShiftWP (outputArrT &out, inputArrT &in, int dx, int dy, bool wrap=true) |
Shift an image by whole pixels with (optional) wrapping. More... | |
template<typename outputArrT , typename inputArrT , typename scaleArrT > | |
void | mx::improc::imageShiftWPScale (outputArrT &out, inputArrT &in, scaleArrT &scale, int dx, int dy) |
Shift an image by whole pixels, wrapping around, with a scaling image applied to the shifted image. More... | |
template<typename arrOutT , typename arrInT , typename floatT1 , typename floatT2 , typename transformT > | |
void | mx::improc::imageShift (arrOutT &transim, const arrInT &im, floatT1 dx, floatT2 dy, transformT trans) |
Shift an image. More... | |
template<typename arrOutT , typename arrInT , typename transformT > | |
void | mx::improc::imageMagnify (arrOutT &transim, const arrInT &im, transformT trans) |
Magnify an image. More... | |
template<typename arrOutT , typename arrInT > | |
void | mx::improc::imageMagnify (arrOutT &transim, const arrInT &im) |
Magnify an image with the cubic convolution interpolator. More... | |
template<typename imageOutT , typename imageInT > | |
int | mx::improc::imageRebinSum (imageOutT &imout, const imageInT &imin, bool mean=false) |
Re-bin an image using the sum, reducing its size while conserving the total flux. More... | |
template<typename imageOutT , typename imageInT > | |
int | mx::improc::imageRebinSum (imageOutT &imout, int &xMax, int &yMax, typename imageOutT::Scalar &pMax, const imageInT &imin, bool mean=false) |
Re-bin an image using the sum, reducing its size while conserving the total flux. Records the value and position of the re-binned max pixel. More... | |
template<typename imageOutT , typename imageInT > | |
int | mx::improc::imageRebinMean (imageOutT &imout, const imageInT &imin) |
Re-bin an image using the mean. More... | |
template<typename imageOutT , typename imageInT > | |
int | mx::improc::imageRebinMean (imageOutT &imout, int &xMax, int &yMax, typename imageOutT::Scalar &pMax, const imageInT &imin, bool mean=false) |
Re-bin an image using the mean. Records the value and position of the re-binned max pixel. More... | |
template<typename imageOutT , typename imageInT > | |
int | mx::improc::imageRebinMeanReject (imageOutT &imout, const imageInT &imin) |
Re-bin an image, takes the mean with a min/max rejection. More... | |
template<typename imageOutT , typename imageInT > | |
int | mx::improc::imageRebinMeanReject (imageOutT &imout, int &xMax, int &yMax, typename imageOutT::Scalar &pMax, const imageInT &imin) |
Re-bin an image, takes the mean with a min/max rejection. Records the value and position of the re-binned max pixel. More... | |
template<typename imageOutT , typename imageInT > | |
void | mx::improc::imageDownSample (imageOutT &imout, const imageInT &imin) |
Down-sample an image, reducing its size while conserving the total flux. More... | |
typedef bilinearTransform<double> mx::improc::bilinearTransd |
Typedef for bilinearTransform with double precision.
Definition at line 73 of file imageTransforms.hpp.
typedef bilinearTransform<float> mx::improc::bilinearTransf |
Typedef for bilinearTransform with single precision.
Definition at line 68 of file imageTransforms.hpp.
typedef cubicConvolTransform<double> mx::improc::cubicConvolTransd |
Typedef for cubicConvolTransform with double precision.
Definition at line 178 of file imageTransforms.hpp.
typedef cubicConvolTransform<float> mx::improc::cubicConvolTransf |
Typedef for cubicConvolTransform with single precision.
Definition at line 173 of file imageTransforms.hpp.
void mx::improc::imageDownSample | ( | imageOutT & | imout, |
const imageInT & | imin | ||
) |
Down-sample an image, reducing its size while conserving the total flux.
If the old size is an integer multiple of the new size, this is just a re-bin. If not an integer multiple, the image is interpolated after performing the closest re-bin, and then re-normalized to conserve flux.
Definition at line 851 of file imageTransforms.hpp.
Referenced by mx::AO::sim::pywfsSlopeReconstructor< _floatT >::calcMeasurement(), and mx::AO::sim::ccdDetector< _realT >::exposeImage().
void mx::improc::imageMagnify | ( | arrOutT & | transim, |
const arrInT & | im | ||
) |
Magnify an image with the cubic convolution interpolator.
Uses the cubic convolution interpolator to magnify the input image to the size of the output image.
This is a wrapper for imageMagnify with the transform type specified.
arrOutT | is the eigen array type of the output. |
arrInT | is the eigen array type of the input. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[out] | transim | contains the magnified image. Must be pre-allocated. |
[in] | im | is the image to be magnified. |
Definition at line 652 of file imageTransforms.hpp.
void mx::improc::imageMagnify | ( | arrOutT & | transim, |
const arrInT & | im, | ||
transformT | trans | ||
) |
Magnify an image.
Uses the given transformation type to magnify the input image to the size of the output image.
Here we assume that the image center is the mxlib standard:
Some care is necessary to prevent magnification from shifting the image with respect to this center. The main result is that the magnification factors (which can be different in x and y) are defined thus:
Example:
In this exmple, the image in im1 will be magnified by 1023.0/511.0 = 2.002x
and placed in im2.
This transform function does not handle edges. If treatment of edges is desired, you must pad the input image using the desired strategy before calling this function. Note that the padded-size of the input image will affect the magnification factor.
arrOutT | is the eigen array type of the output. |
arrInT | is the eigen array type of the input. |
transformT | specifies the transformation to use. |
[out] | transim | contains the magnified image. Must be pre-allocated. |
[in] | im | is the image to be magnified. |
[in] | trans | is the transformation to use |
Definition at line 561 of file imageTransforms.hpp.
Referenced by mx::improc::imageMaxInterp().
int mx::improc::imageRebinMean | ( | imageOutT & | imout, |
const imageInT & | imin | ||
) |
Re-bin an image using the mean.
This is a wrapper for imageRebinSum with mean=true
.
[out] | imout | the re-binned image. Must be allocated to size which is an integer factor smaller than imin. |
[in] | imin | the image to rebin |
Definition at line 730 of file imageTransforms.hpp.
References mx::improc::imageRebinSum().
int mx::improc::imageRebinMean | ( | imageOutT & | imout, |
int & | xMax, | ||
int & | yMax, | ||
typename imageOutT::Scalar & | pMax, | ||
const imageInT & | imin, | ||
bool | mean = false |
||
) |
Re-bin an image using the mean. Records the value and position of the re-binned max pixel.
This is a wrapper for imageRebinSum with mean=true
.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[out] | imout | the re-binned image. Must be allocated to size which is an integer factor smaller than imin. |
[out] | xMax | the x-locatioin of the max pixel |
[out] | yMax | the y-locatioin of the max pixel |
[out] | pMax | the value of the max pixel |
[in] | imin | the image to rebin |
[in] | mean | if true the output is the mean rather than the sum. |
Definition at line 743 of file imageTransforms.hpp.
References mx::improc::imageRebinSum().
int mx::improc::imageRebinMeanReject | ( | imageOutT & | imout, |
const imageInT & | imin | ||
) |
Re-bin an image, takes the mean with a min/max rejection.
The mean is calculated after rejecting the minimuma and maximum value.
[out] | imout | the re-binned image. Must be allocated to size which is an integer factor smaller than imin. |
[in] | imin | the image to rebin |
Definition at line 758 of file imageTransforms.hpp.
References mx::astro::constants::k().
int mx::improc::imageRebinMeanReject | ( | imageOutT & | imout, |
int & | xMax, | ||
int & | yMax, | ||
typename imageOutT::Scalar & | pMax, | ||
const imageInT & | imin | ||
) |
Re-bin an image, takes the mean with a min/max rejection. Records the value and position of the re-binned max pixel.
The mean is calculated after rejecting the minimuma and maximum value.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[out] | imout | the re-binned image. Must be allocated to size which is an integer factor smaller than imin. |
[out] | xMax | the x-locatioin of the max pixel |
[out] | yMax | the y-locatioin of the max pixel |
[out] | pMax | the value of the max pixel |
[in] | imin | the image to rebin |
Definition at line 797 of file imageTransforms.hpp.
References mx::astro::constants::k().
int mx::improc::imageRebinSum | ( | imageOutT & | imout, |
const imageInT & | imin, | ||
bool | mean = false |
||
) |
Re-bin an image using the sum, reducing its size while conserving the total flux.
Optionally this can be the mean instead of the sum filter, in which case total flux is not conserved.
[out] | imout | the re-binned image. Must be allocated to size which is an integer factor smaller than imin. |
[in] | imin | the image to rebin |
[in] | mean | if true the output is the mean rather than the sum. |
Definition at line 663 of file imageTransforms.hpp.
int mx::improc::imageRebinSum | ( | imageOutT & | imout, |
int & | xMax, | ||
int & | yMax, | ||
typename imageOutT::Scalar & | pMax, | ||
const imageInT & | imin, | ||
bool | mean = false |
||
) |
Re-bin an image using the sum, reducing its size while conserving the total flux. Records the value and position of the re-binned max pixel.
Optionally this can be the mean instead of the sum filter, in which case total flux is not conserved.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[out] | imout | the re-binned image. Must be allocated to size which is an integer factor smaller than imin. |
[out] | xMax | the x-locatioin of the max pixel |
[out] | yMax | the y-locatioin of the max pixel |
[out] | pMax | the value of the max pixel |
[in] | imin | the image to rebin |
[in] | mean | if true the output is the mean rather than the sum. |
Definition at line 690 of file imageTransforms.hpp.
Referenced by mx::improc::imageRebinMean().
void mx::improc::imageRotate | ( | arrT & | transim, |
const arrT2 & | im, | ||
floatT | dq, | ||
transformT | trans | ||
) |
Rotate an image represented as an eigen array.
Uses the given transformation type to rotate an image.
transformT | specifies the transformation to use [will be resolved by compiler] |
arrT | is the eigen array type of the output [will be resolved by compiler] |
arrT2 | is the eigen array type of the input [will be resolved by compiler] |
floatT | is a floating point type [will be resolved by compiler in most cases] |
[out] | transim | The rotated image. Must be pre-allocated. |
[in] | im | The image to be rotated. |
[in] | dq | the angle, in radians, by which to rotate in the c.c.w. direction |
[in] | trans | is the transformation to use |
Definition at line 195 of file imageTransforms.hpp.
Referenced by mx::improc::ADIobservation< _realT, _derotFunctObj >::derotate(), and mx::improc::rotateMask().
void mx::improc::imageShift | ( | arrOutT & | transim, |
const arrInT & | im, | ||
floatT1 | dx, | ||
floatT2 | dy, | ||
transformT | trans | ||
) |
Shift an image.
Uses the given transformation type to shift an image such that objects move by (dx
,dy
) pixels.
The shift is such that an object located at the coordinate (-dx
, -dy
) from the center of the image will be moved to the center of the image. So to move an object located 2 pixels right (dx) and 2 pixels up (dy) from the center to be at the center, use dx
= -2, dy
= -2.
Note that this does not treat the edges of the image, determined by the buffer width (lbuff) of the kernel and the size of shift. If you wish to treat the edges, you must pad the image by at least lbuff+abs(shift) pixels in each direction, and implement a strategy (zeros, mirror, wrap) prior to calling this function.
arrOutT | is the Eigen-like array type of the output [will be resolved by compiler] |
arrInT | is the Eigen-like array type of the input [will be resolved by compiler] |
floatT1 | is a floating point type [will be resolved by compiler] |
floatT2 | is a floating point type [will be resolved by compiler] |
transformT | specifies the transformation to use [will be resolved by compiler] |
[out] | transim | Will contain the shifted image. Will be allocated. |
[in] | im | the image to be shifted. |
[in] | dx | the amount to shift in the x direction |
[in] | dy | the amount to shift in the y direction |
[in] | trans | trans is the transformation to use |
Definition at line 453 of file imageTransforms.hpp.
References mx::improc::imageShiftWP().
Referenced by SCENARIO(), mx::AO::sim::turbLayer< _aoSystemT >::shift(), and mx::AO::sim::turbLayer< _aoSystemT >::shiftRandom().
void mx::improc::imageShiftWP | ( | outputArrT & | out, |
inputArrT & | in, | ||
int | dx, | ||
int | dy, | ||
bool | wrap = true |
||
) |
Shift an image by whole pixels with (optional) wrapping.
The output image can be smaller than the input image, in which case the wrapping (if enabled) still occurs for the input image, but only output images worth of pixels are actually shifted. This is useful, for instance, when propagating large turbulence phase screens where one only needs a small section at a time.
outputArrT | is the eigen array type of the output [will be resolved by compiler] |
inputArrT | is the eigen array type of the input [will be resolved by compiler] |
[out] | out | contains the shifted image. Must be pre-allocated, but can be smaller than the in array. |
[in] | in | the image to be shifted. |
[in] | dx | the amount to shift in the x direction |
[in] | dy | the amount to shift in the y direction |
[in] | wrap | flag controlling whether or not to wrap around |
Definition at line 296 of file imageTransforms.hpp.
Referenced by mx::improc::imageShift(), mx::improc::imageXCorrFFT< _ccImT >::refIm(), mx::AO::sim::turbLayer< _aoSystemT >::shift(), and mx::AO::sim::turbLayer< _aoSystemT >::shiftRandom().
void mx::improc::imageShiftWPScale | ( | outputArrT & | out, |
inputArrT & | in, | ||
scaleArrT & | scale, | ||
int | dx, | ||
int | dy | ||
) |
Shift an image by whole pixels, wrapping around, with a scaling image applied to the shifted image.
The output image can be smaller than the input image, in which case the wrapping still occurs for the input image, but only output images worth of pixels are actually shifted. This is useful, for instance, when propagating large turbulence phase screens where one only needs a small section at a time.
The scaling is applied to the output image. The scale image must be the same size as the output image.
outputArrT | is the eigen array type of the output [will be resolved by compiler] |
inputArrT | is the eigen array type of the input [will be resolved by compiler] |
scaleArrT | is the eigen array type of the scale image [will be resolved by compiler] |
[out] | out | contains the shifted image. Must be pre-allocated, but can be smaller than the in array. |
[in] | in | the image to be shifted. |
[in] | scale | image of scale values applied per-pixel to the output (shifted) image, same size as out |
[in] | dx | the amount to shift in the x direction |
[in] | dy | the amount to shift in the y direction |
Definition at line 389 of file imageTransforms.hpp.