1 #ifndef TIL_RECURSIVE_FILTER1_H 2 #define TIL_RECURSIVE_FILTER1_H 22 template <
typename T,
int direction>
45 T
getMI()
const {
return m_mi0; }
47 T
getMO()
const {
return m_mo0; }
66 void apply(
const std::vector<T> &in, std::vector<T> &out)
const;
73 T borderFactor()
const {
return m_mi0 /(1 + m_mo0); }
75 T mirrorBC(
const std::vector<T> &in,
size_t length)
const;
77 T
apply(T in0, T out0)
const 79 return m_mi0 * in0 - m_mo0 * out0;
93 template <
typename T,
int direction >
96 assert(in.size() == out.size());
98 size_t length = in.size();
100 typename std::vector<T>::const_iterator pIn;
101 typename std::vector<T>::iterator pOut;
108 else if (direction == -1)
110 pIn = in.begin() + length - 1;
111 pOut = out.begin() + length - 1;
119 switch (m_boundaryConditions)
125 y0 = *pIn * this->borderFactor();
127 y0 = this->mirrorBC(in, length);
130 for(
size_t count = 0; count < length; ++count)
134 *pOut += y0 = this->
apply(x0, y0);
139 template <
typename T,
int direction >
142 const T EPSILON = std::numeric_limits<T>::epsilon() * 128;
143 typename std::vector<T>::const_iterator pIn;
150 else if (direction == -1)
152 pIn == in.begin() + length - 1;
161 for(count = 0; count < length; ++count)
163 res += (*pIn)*factor;
165 if (factor <= EPSILON)
return res;
172 for(count = 1; count < length; ++count)
174 res += (*pIn)*factor;
176 if (factor <= EPSILON)
return res;
180 return res / (1 - factor * m_mo0);
INLINE void apply(const Affine< T1 > &a, const numeric_array< T2, 3 > &in, numeric_array< typename combine< T1, T2 >::type, 3 > &out)
Belongs to package Box Do not include directly, include til/Box.h instead.
General macros, definitions and functions.
RecursiveFilter< T, direction, 1 > Self
void setFilter(T mi0, T mo0)
void setBoundaryConditions(BoundaryConditions bc)