20 #ifndef MIRTK_VoxelDomain_H 21 #define MIRTK_VoxelDomain_H 70 namespace ForEachVoxelDomain {
79 static inline bool IsInside(
const BaseImage &image,
int idx,
const void *)
84 static inline bool IsInside(
const BaseImage &image,
int i,
int j,
int k,
int l,
const void *)
97 static inline bool IsInside(
const BaseImage &image,
int,
const T *p)
100 return (*p != bg) && (bg == bg || *p == *p );
104 static inline bool IsInside(
const BaseImage &image,
int,
int,
int,
int,
const T *p)
107 return (*p != bg) && (bg == bg || *p == *p );
118 static inline bool IsInside(
const BaseImage &image,
int,
const T *p)
121 return (*p > bg) && (bg == bg || *p == *p );
125 static inline bool IsInside(
const BaseImage &image,
int,
int,
int,
int,
const T *p)
128 return (*p > bg) && (bg == bg || *p == *p );
138 static inline bool IsInside(
const BaseImage &image,
int idx,
const void *)
143 static inline bool IsInside(
const BaseImage &image,
int i,
int j,
int k,
int l,
const void *)
156 static inline bool IsInside(
const BaseImage &image,
int,
const T *p)
159 return (*p == bg) || (bg != bg && *p != *p );
163 static inline bool IsInside(
const BaseImage &image,
int,
int,
int,
int,
const T *p)
166 return (*p == bg) || (bg != bg && *p != *p );
176 static inline bool IsInside(
const BaseImage &image,
int idx,
const void *)
179 if (mask->
GetT() > 1) {
180 return (mask->
Get(idx) != BinaryPixel(0));
182 return (mask->
Get(idx % (image.
GetX() * image.
GetY() * image.
GetZ())) != BinaryPixel(0));
186 static inline bool IsInside(
const BaseImage &image,
int i,
int j,
int k,
int l,
const void *)
189 return (mask->
Get(i, j, k, mask->
GetT() > 1 ? l : 0) != BinaryPixel(0));
202 static inline bool IsInside(
const BaseImage &image,
int idx,
const void *)
207 static inline bool IsInside(
const BaseImage &image,
int i,
int j,
int k,
int,
const void *)
209 return (image.
GetMask()->
Get(i, j, k) != BinaryPixel(0));
226 namespace InterpolationDomain {
239 template <
class InterpolateImageFunction>
240 static inline bool IsInside(
InterpolateImageFunction *interpolator,
const double &x,
const double &y,
const double &z)
264 template <
class InterpolateImageFunction>
265 static inline bool IsInside(
InterpolateImageFunction *interpolator,
const double &x,
const double &y,
const double &z)
267 return interpolator->
IsInside(x, y, z);
277 #endif // MIRTK_VoxelDomain_H double GetBackgroundValueAsDouble() const
Get background value.
bool IsBackground(int) const
Whether voxel is within background without index-out-of-bounds check.
BinaryImage * GetMask(bool=false)
Get foreground mask (optionally, take over ownership)
bool IsForeground(int) const
Whether voxel is within foreground without index-out-of-bounds check.
bool IsInside(double, double) const
int GetX() const
Returns the number of voxels in the x-direction.
int GetT() const
Returns the number of voxels in the t-direction.
int GetY() const
Returns the number of voxels in the y-direction.
bool IsForeground(double, double) const
VoxelType Get(int) const
Function for pixel get access.
int GetZ() const
Returns the number of voxels in the z-direction.