1 #ifndef TIL_CONSTIMAGENCVOLUMETRICITERATOR_H 2 #define TIL_CONSTIMAGENCVOLUMETRICITERATOR_H 16 template <
typename T >
class ImageNC;
24 template <
typename T >
91 return m_im.getUnsafeValue(
92 this->pos()[0] + offsetx,
93 this->pos()[1] + offsety,
94 this->pos()[2] + offsetz);
97 template <
int offsetx,
int offsety,
int offsetz >
103 if (offsetz)
return m_im.getUnsafeValue( this->pos()[0] + offsetx, this->pos()[1] + offsety, this->pos()[2] + offsetz);
104 else return *(m_index + offsetx + offsety * m_offset[1] );
107 template <
class Extrapolator,
int offsetx,
int offsety,
int offsetz >
110 if (containsNeighbor<offsetx, offsety, offsetz>(*
this))
112 return this->getUnsafeValue<offsetx, offsety, offsetz>();
116 return Extrapolator::getExtrapolatedValue(m_im, this->pos() +
129 template <
class Extrapolator >
130 T
getValue(
int offsetx,
int offsety,
int offsetz)
const 132 return Extrapolator::getValue(m_im,
133 this->pos()[0] + offsetx,
134 this->pos()[1] + offsety,
135 this->pos()[2] + offsetz);
138 template <
class Extrapolator >
148 return m_im.getValue(
149 this->pos()[0] + offsetx,
150 this->pos()[1] + offsety,
151 this->pos()[2] + offsetz);
169 bool isAtEnd()
const {
return (m_index == 0); }
231 template <
typename T >
244 throw std::domain_error(
"ROI lies outside image range");
250 m_index = m_im.getUnsafePointerOf(m_pos);
253 m_offset[1] = m_im.dim()[0];
254 m_offset[2] = m_im.dim()[0]*m_im.dim()[1];
260 template <
typename T >
274 template <
typename T >
280 if (++(m_pos[0]) > m_roi.max_bounds()[0])
282 m_pos[0] = m_roi.min_bounds()[0];
284 if (++(m_pos[1]) > m_roi.max_bounds()[1])
286 m_pos[1] = m_roi.min_bounds()[1];
288 if (++(m_pos[2]) > m_roi.max_bounds()[2])
296 m_index = m_im.getUnsafePointerOf(m_pos);
323 template <
typename T >
327 throw std::out_of_range(
"Point does not lie within iterator range");
328 this->setUnsafePos(pos);
342 template <
typename T >
346 m_index = m_im.getUnsafePointerOf(m_pos);
349 template <
typename T >
354 if (++m_pos[axis] > m_roi.max_bounds()[0])
362 m_index += m_offset[axis];
367 template <
typename T >
370 std::cout <<
"Pointer: " << it.m_index << std::endl;
371 std::cout <<
"Position: " << it.m_pos << std::endl;
372 std::cout <<
"Offset: " << it.m_offset << std::endl;
373 std::cout <<
"Range: " << it.m_roi.min_bounds() <<
" "<< it.m_roi.max_bounds() << std::endl;
numeric_array< int, 3 > m_offset
const numeric_array< int, 3 > & pos() const
const T *const getIndex()
INLINE T getUnsafeValue() const
INLINE T operator()(const numeric_array< int, 3 > &v) const
Belongs to package Box Do not include directly, include til/Box.h instead.
void printInfo(ConstVolumetricIterator< ImageNC< T > > &it)
numeric_array< int, 3 > m_pos
General macros, definitions and functions.
Defines empty classes that serves as labels.
const numeric_array< T, D > & min_bounds() const
Get min bounds.
INLINE T operator()(int offsetx, int offsety, int offsetz) const
const ImageNC< T > & image() const
T getValue(int offsetx, int offsety, int offsetz) const
INLINE T getUnsafeValue(int offsetx, int offsety, int offsetz) const
Image class storing data slice-by-slice.
boost::enable_if< is_numeric_container< TStorage >, bool >::type contains(const Box< T, D > &box, const TStorage &v)
Check whether a point lies within box.
Range< int, 3 > getRange(const TImage &im)
Get image range.
INLINE T getValue() const
const Range< int, 3 > & getRoi() const
T getValue(const numeric_array< int, 3 > &offset) const
reference operator*() const
TIL_API ImageAxis operator++(ImageAxis &axis)