|
mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Using the Eigen matrix library for image processing
Classes | |
| class | mx::improc::eigenCube< dataT > |
| An image cube with an Eigen-like API. More... | |
| struct | mx::improc::is_eigenCube< T > |
| Test whether a type is an eigenCube by testing whether it has a typedef of "is_eigenCube". More... | |
| struct | mx::improc::eigenArrPlanes< arrT, isCube > |
| Function object to return the number of planes for any Eigen like object, whether 2D or a 3D cube. More... | |
Typedefs | |
| template<typename scalarT> | |
| using | mx::improc::eigenImage = Eigen::Array<scalarT, -1, -1> |
| Definition of the eigenImage type, which is an alias for Eigen::Array. | |
| template<typename scalarT> | |
| using | mx::improc::eigenMap = Eigen::Map<Eigen::Array<scalarT, -1, -1>> |
| Definition of the eigenMap type, which is an alias for Eigen::Map<Array>. | |
Functions | |
| template<class imageT, typename valueT> | |
| void | mx::improc::zeroNaNs (imageT &im, valueT val) |
| Zero any NaNs in an image. | |
| template<class imageT> | |
| void | mx::improc::zeroNaNs (imageT &im) |
| Zero any NaNs in an image. | |
| template<class cubeT, class maskCubeT> | |
| void | mx::improc::zeroNaNCube (cubeT &imc, maskCubeT *mask) |
| Zero any NaNs in an image cube. | |
| template<class cubeT> | |
| void | mx::improc::zeroNaNCube (cubeT &imc) |
| Zero any NaNs in an image cube. | |
| template<class calcT, class imageT> | |
| calcT | mx::improc::imageMean (imageT &im) |
| Calculate the mean value of an image. | |
| template<class calcT, class imageT, class maskT> | |
| calcT | mx::improc::imageMean (imageT &im, const maskT &mask) |
| Calculate the mean value of an image over a mask. | |
| template<typename calcT, class imageT> | |
| calcT | mx::improc::imageVariance (imageT &im, calcT mn) |
| Calculate the variance of an image given its mean. | |
| template<typename calcT, class imageT, class maskT> | |
| calcT | mx::improc::imageVariance (imageT &im, calcT mn, const maskT &mask) |
| Calculate the variance of an image given its mean. | |
| template<typename imageT, typename maskT = imageT> | |
| imageT::Scalar | mx::improc::imageMedian (const imageT &mat, const maskT *mask, std::vector< typename imageT::Scalar > *work=0) |
| Calculate the median of an Eigen-like array. | |
| template<typename imageT> | |
| imageT::Scalar | mx::improc::imageMedian (const imageT &mat, std::vector< typename imageT::Scalar > *work=0) |
| Calculate the median of an Eigen-like array. | |
| template<typename imageT> | |
| int | mx::improc::imageCenterOfLight (typename imageT::Scalar &x, typename imageT::Scalar &y, const imageT &im) |
| Calculate the center of light of an image. | |
| template<typename floatT, typename imageT, typename magImageT, typename transformT> | |
| int | mx::improc::imageMaxInterp (floatT &x, floatT &y, floatT &scale_x, floatT &scale_y, magImageT &magIm, const imageT &im, transformT trans) |
| Find the maximum in an image at sub-pixel resolution by interpolation. | |
| template<typename floatT, typename imageT, typename magImageT> | |
| int | mx::improc::imageMaxInterp (floatT &x, floatT &y, floatT &scale_x, floatT &scale_y, magImageT &magIm, const imageT &im) |
| Find the maximum in an image at sub-pixel resolution by cubic convolution interpolation. | |
| template<typename imageT, typename imageT1, typename imageT2, typename imageT3, typename imageT4> | |
| void | mx::improc::combine2ImagesMasked (imageT &combo, const imageT1 &im1, const imageT2 &mask1, const imageT3 &im2, const imageT4 &mask2) |
| Combine two images, each with their own mask defining good pixels. | |
| template<typename eigenT, typename eigenTin> | |
| void | mx::improc::removeRowsAndCols (eigenT &out, const eigenTin &in, int st, int w) |
| Remove rows and columns. | |
| template<typename eigenT, typename eigenTin> | |
| void | mx::improc::removeRows (eigenT &out, const eigenTin &in, int st, int w) |
| Remove rows. | |
| template<typename eigenT, typename eigenTin> | |
| void | mx::improc::removeCols (eigenT &out, const eigenTin &in, int st, int w) |
| Remove columns. | |
| using mx::improc::eigenImage = Eigen::Array<scalarT, -1, -1> |
Definition of the eigenImage type, which is an alias for Eigen::Array.
Definition at line 44 of file eigenImage.hpp.
| using mx::improc::eigenMap = Eigen::Map<Eigen::Array<scalarT, -1, -1>> |
Definition of the eigenMap type, which is an alias for Eigen::Map<Array>.
Definition at line 50 of file eigenImage.hpp.
| void mx::improc::combine2ImagesMasked | ( | imageT & | combo, |
| const imageT1 & | im1, | ||
| const imageT2 & | mask1, | ||
| const imageT3 & | im2, | ||
| const imageT4 & | mask2 ) |
Combine two images, each with their own mask defining good pixels.
The combined image is made up of the pixels in im1 where mask1 is 1, and the pixels of im2 where mask2 is 1. If a pixel in both mask1 and mask2 has a value of 1, that pixel in the combo is the average of im1 and im2. All other pixels are set to 0 in the combined image.
Separate template types are used for each argument to allow references, etc.
| imageT | the eigen-like array type of the combined image |
| imageT1 | the eigen-like array type of image 1 |
| imageT2 | the eigen-like array type of mask 1 |
| imageT3 | the eigen-like array type of image 2 |
| imageT4 | the eigen-like array type of mask 2 |
| [out] | combo | the combined image. will be resized. |
| [in] | im1 | the first image |
| [in] | mask1 | the mask for the first image |
| [in] | im2 | the second image |
| [in] | mask2 | the mask for the second image |
Definition at line 483 of file imageUtils.hpp.
| int mx::improc::imageCenterOfLight | ( | typename imageT::Scalar & | x, |
| typename imageT::Scalar & | y, | ||
| const imageT & | im ) |
Calculate the center of light of an image.
Note that the sum of the image should be > 0.
| [out] | x | the x coordinate of the center of light [pixels] |
| [out] | y | the y coordinate of hte center of light [pixels] |
| [in] | im | the image to centroid |
Definition at line 374 of file imageUtils.hpp.
Referenced by circleOuterpix(), mx::improc::imageXCorrFFT< _realImageT >::findPeak(), mx::improc::imageXCorrDiscrete< _ccImT >::operator()(), TEST_CASE(), and TEST_CASE().
| int mx::improc::imageMaxInterp | ( | floatT & | x, |
| floatT & | y, | ||
| floatT & | scale_x, | ||
| floatT & | scale_y, | ||
| magImageT & | magIm, | ||
| const imageT & | im ) |
Find the maximum in an image at sub-pixel resolution by cubic convolution interpolation.
Uses imageMagnify() to expand the image to the desired scale. Because of the scaling used in imageMagnify, the desired scale may not be exact. As a result the actual scale is returned in scale_x and scale_y.
| [out] | x | the x-position of the maximum, in pixels of the input image |
| [out] | y | the y-position of the maximum, in pixels of the input image |
| scale_x | [in.out] the desired scale or resolution, in pixels < 1, in the x direction. On output contains the actual scale calculated. | |
| scale_y | [in.out] the desired scale or resolution, in pixels < 1, in the y direction. On output contains the actual scale calculated. | |
| [in] | magIm | the magnified image. This is used as working memory, will be resized. |
| [in] | im | the image to find the maximum of |
Definition at line 454 of file imageUtils.hpp.
References imageMaxInterp().
| int mx::improc::imageMaxInterp | ( | floatT & | x, |
| floatT & | y, | ||
| floatT & | scale_x, | ||
| floatT & | scale_y, | ||
| magImageT & | magIm, | ||
| const imageT & | im, | ||
| transformT | trans ) |
Find the maximum in an image at sub-pixel resolution by interpolation.
Uses imageMagnify() to expand the image to the desired scale. Because of the scaling used in imageMagnify, the desired scale may not be exact. As a result the actual scale is returned in scale_x and scale_y.
| [out] | x | the x-position of the maximum, in pixels of the input image |
| [out] | y | the y-position of the maximum, in pixels of the input image |
| scale_x | [in.out] the desired scale or resolution, in pixels < 1, in the x direction. On output contains the actual scale calculated. | |
| scale_y | [in.out] the desired scale or resolution, in pixels < 1, in the y direction. On output contains the actual scale calculated. | |
| [in] | magIm | the magnified image. This is used as working memory, will be resized. |
| [in] | im | the image to find the maximum of |
| [in] | trans | the transform to use for interpolation |
Definition at line 414 of file imageUtils.hpp.
References imageMagnify().
Referenced by imageMaxInterp().
| calcT mx::improc::imageMean | ( | imageT & | im | ) |
Calculate the mean value of an image.
| [in] | im | the image of which to calculate the mean |
Definition at line 221 of file imageUtils.hpp.
Referenced by mx::improc::imageXCorrDiscrete< _ccImT >::operator()(), mx::improc::imageXCorrFFT< _realImageT >::operator()(), mx::improc::imageXCorrDiscrete< _ccImT >::refIm(), and mx::improc::imageXCorrFFT< _realImageT >::refIm().
| calcT mx::improc::imageMean | ( | imageT & | im, |
| const maskT & | mask ) |
Calculate the mean value of an image over a mask.
| [in] | im | the image of which to calculate the mean |
| [in] | mask | a 1/0 mask where 1 defines the good pixels |
Definition at line 233 of file imageUtils.hpp.
| imageT::Scalar mx::improc::imageMedian | ( | const imageT & | mat, |
| const maskT * | mask, | ||
| std::vector< typename imageT::Scalar > * | work = 0 ) |
Calculate the median of an Eigen-like array.
Calculates the median of the entire array, allowing for some pixels to be ignored using a mask. Working memory can be retained between calls.
| imageT | is an Eigen-like type |
| maskT | is an Eigen-like type |
| [in] | mat | the image to take the median of |
| [in] | mask | if non-0, a 1/0 mask where 0 pixels are ignored. |
| [in] | work | [optional] working memory can be retained and re-passed. Is resized. |
Definition at line 284 of file imageUtils.hpp.
References mx::math::vectorMedianInPlace().
Referenced by mx::sigproc::basisAmplitudes(), imageMedian(), mx::improc::eigenCube< dataT >::median(), TEST_CASE(), and unitTest::improcTest::eigenCubeTest::TEST_CASE().
| imageT::Scalar mx::improc::imageMedian | ( | const imageT & | mat, |
| std::vector< typename imageT::Scalar > * | work = 0 ) |
Calculate the median of an Eigen-like array.
Calculates the median of the entire array. Working memory can be retained between calls.
| imageT | is an Eigen-like type |
| [in] | mat | the image to take the median of |
| [in] | work | [optional] working memory can be retained and re-passed. |
Definition at line 360 of file imageUtils.hpp.
References imageMedian().
| calcT mx::improc::imageVariance | ( | imageT & | im, |
| calcT | mn ) |
Calculate the variance of an image given its mean.
| [in] | im | the image of which to calculate the variance |
| [in] | mn | the mean value of the image w.r.t. which to calcualate the variance |
Definition at line 247 of file imageUtils.hpp.
Referenced by mx::improc::imageXCorrDiscrete< _ccImT >::operator()(), mx::improc::imageXCorrFFT< _realImageT >::operator()(), mx::improc::imageXCorrDiscrete< _ccImT >::refIm(), and mx::improc::imageXCorrFFT< _realImageT >::refIm().
| calcT mx::improc::imageVariance | ( | imageT & | im, |
| calcT | mn, | ||
| const maskT & | mask ) |
Calculate the variance of an image given its mean.
| [in] | im | the image of which to calculate the variance |
| [in] | mn | the mean value of the image w.r.t. which to calcualate the variance |
| [in] | mask | a 1/0 mask where 1 defines the good pixels |
Definition at line 262 of file imageUtils.hpp.
| void mx::improc::removeCols | ( | eigenT & | out, |
| const eigenTin & | in, | ||
| int | st, | ||
| int | w ) |
Remove columns.
Definition at line 547 of file imageUtils.hpp.
| void mx::improc::removeRows | ( | eigenT & | out, |
| const eigenTin & | in, | ||
| int | st, | ||
| int | w ) |
Remove rows.
Definition at line 532 of file imageUtils.hpp.
| void mx::improc::removeRowsAndCols | ( | eigenT & | out, |
| const eigenTin & | in, | ||
| int | st, | ||
| int | w ) |
Remove rows and columns.
Definition at line 513 of file imageUtils.hpp.
| void mx::improc::zeroNaNCube | ( | cubeT & | imc | ) |
Zero any NaNs in an image cube.
| imc | [in.out] cube which will have any NaN pixels set to zero |
Definition at line 208 of file imageUtils.hpp.
References zeroNaNCube().
| void mx::improc::zeroNaNCube | ( | cubeT & | imc, |
| maskCubeT * | mask ) |
Zero any NaNs in an image cube.
This version fills in a mask with 1s where there were nans, 0s elsewhere.
| imc | [in.out] cube which will have any NaN pixels set to zero | |
| [out] | mask | a 1/0 mask with 1 indicating which pixels where nan |
Definition at line 174 of file imageUtils.hpp.
References isInvalidPixel().
Referenced by TEST_CASE(), and zeroNaNCube().
| void mx::improc::zeroNaNs | ( | imageT & | im | ) |
Zero any NaNs in an image.
| im | [in.out] image which will have any NaN pixels set to zero |
Definition at line 162 of file imageUtils.hpp.
References zeroNaNs().
| void mx::improc::zeroNaNs | ( | imageT & | im, |
| valueT | val ) |
Zero any NaNs in an image.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| im | [in.out] image which will have any NaN pixels set to zero | |
| [in] | val | [optional] The value to set NaN pixels too. Default is 0. |
Definition at line 141 of file imageUtils.hpp.
References isInvalidPixel().
Referenced by unitTest::improcTest::imageFiltersTest::TEST_CASE(), unitTest::improcTest::imageFiltersTest::TEST_CASE(), and zeroNaNs().