27 #ifndef improc_eigenImage_hpp
28 #define improc_eigenImage_hpp
30 #pragma GCC system_header
31 #include <Eigen/Dense>
33 #include "../math/vectorUtils.hpp"
43 template<
typename scalarT>
49 template<
typename scalarT>
50 using eigenMap = Eigen::Map<Eigen::Array<scalarT, -1, -1>>;
72 template <
typename imageT>
73 static yes& test(
typename imageT::is_eigenCube*);
80 static const bool value =
sizeof(test<T>(0)) ==
sizeof(yes);
89 template<typename arrT, bool isCube=is_eigenCube<arrT>::value>
93 int operator()(
const arrT & arr)
99 template<
typename arrT>
103 int operator()(
const arrT & arr)
121 template<
typename imageT,
typename maskT=imageT>
124 std::vector<typename imageT::Scalar> * work =0
127 typename imageT::Scalar med;
129 bool localWork =
false;
132 work =
new std::vector<typename imageT::Scalar>;
146 for(
int i=0;i<mat.rows();++i)
148 for(
int j=0; j<mat.cols();++j)
152 if( (*mask)(i,j) == 0)
continue;
155 (*work)[ii] = mat(i,j);
163 if(localWork)
delete work;
179 template<
typename imageT>
181 std::vector<typename imageT::Scalar> * work =0
184 return imageMedian( mat, (Eigen::Array<typename imageT::Scalar,-1,-1> *) 0, work);
Eigen::Array< scalarT, -1, -1 > eigenImage
Definition of the eigenImage type, which is an alias for Eigen::Array.
Eigen::Map< Eigen::Array< scalarT, -1, -1 > > eigenMap
Definition of the eigenMap type, which is an alias for Eigen::Map<Array>.
imageT::Scalar imageMedian(const imageT &mat, std::vector< typename imageT::Scalar > *work=0)
Calculate the median of an Eigen-like array.
vectorT::value_type vectorMedianInPlace(vectorT &vec)
Calculate median of a vector in-place, altering the vector.
Function object to return the number of planes for any Eigen like object, whether 2D or a 3D cube.
Test whether a type is an eigenCube by testing whether it has a typedef of "is_eigenCube".