37#ifndef AIMS_UTILITY_THRESHOLD_H
38#define AIMS_UTILITY_THRESHOLD_H
45#include <cartodata/volume/volume.h>
92template <
class T,
class U>
129template <
class T,
class U>
157template <
class T,
class U>
inline
164template <
class T,
class U>
inline
174 template <
typename LEFT,
typename OP>
175 struct thresh1:
public std::unary_function<LEFT, LEFT>
193 template <
typename T>
196 bool operator() (
const T & x,
const T & y,
const T & z)
const
198 return x >= y && x <= z;
203 template <
typename T>
206 bool operator() (
const T & x,
const T & y,
const T & z)
const
208 return x > y && x <= z;
213 template <
typename T>
216 bool operator() (
const T & x,
const T & y,
const T & z)
const
218 return x >= y && x < z;
223 template <
typename T>
226 bool operator() (
const T & x,
const T & y,
const T & z)
const
228 return x > y && x < z;
233 template <
typename T>
236 bool operator() (
const T & x,
const T & y,
const T & z)
const
238 return x <= y || x >= z;
243 template <
typename T>
246 bool operator() (
const T & x,
const T & y,
const T & z)
const
248 return x < y || x >= z;
253 template <
typename T>
256 bool operator() (
const T & x,
const T & y,
const T & z)
const
258 return x <= y || x > z;
263 template <
typename T>
266 bool operator() (
const T & x,
const T & y,
const T & z)
const
268 return x < y || x > z;
273 template <
typename LEFT,
typename OP>
274 struct thresh2:
public std::unary_function<LEFT, LEFT>
294template <
class T,
class U>
inline
395 template <
typename LEFT,
typename OP>
396 struct clip1:
public std::unary_function<LEFT, LEFT>
412 template <
typename T>
419 return x <= z ? 0 : 1;
424 template <
typename T>
431 return x <= z ? 0 : 1;
436 template <
typename T>
443 return x < z ? 0 : 1;
448 template <
typename T>
455 return x < z ? 0 : 1;
460 template <
typename LEFT,
typename OP>
461 struct clip2:
public std::unary_function<LEFT, LEFT>
489template <
class T,
class U>
inline
553 std::cerr <<
"Warning: AimsThreshold cannot use clipping with this mode, "
554 "using standard clipping instead." << std::endl;
562template <
class T,
class U>
inline
566 unsigned i, n = sqv.
nItem(), t , tm = sqv.size();
571 for (t = 0; t < tm ; ++t)
572 for (i = 0; i < n ; ++i)
577 for (t = 0; t < tm ; ++t)
578 for (i = 0; i < n ; ++i)
583 for (t = 0; t < tm ; ++t)
584 for (i = 0; i < n ; ++i)
589 for (t = 0; t < tm ; ++t)
590 for (i = 0; i < n ; ++i)
595 for (t = 0; t < tm ; ++t)
596 for (i = 0; i < n ; ++i)
601 for (t = 0; t < tm ; ++t)
602 for (i = 0; i < n ; ++i)
607 for (t = 0; t < tm ; ++t)
608 for (i = 0; i < n ; ++i)
613 for (t = 0; t < tm ; ++t)
614 for (i = 0; i < n ; ++i)
619 for (t = 0; t < tm ; ++t)
620 for (i = 0; i < n ; ++i)
625 for (t = 0; t < tm ; ++t)
626 for (i = 0; i < n ; ++i)
631 for (t = 0; t < tm ; ++t)
632 for (i = 0; i < n ; ++i)
637 for (t = 0; t < tm ; ++t)
638 for (i = 0; i < n ; ++i)
643 for (t = 0; t < tm ; ++t)
644 for (i = 0; i < n ; ++i)
649 for (t = 0; t < tm ; ++t)
650 for (i = 0; i < n ; ++i)
663 template <
typename LEFT,
typename RIGHT,
typename OP>
682 template <
typename LEFT,
typename RIGHT,
typename OP>
703template <
class T,
class U>
inline
807template <
class T,
class U>
inline
810 unsigned i, n = sqv.
nItem(), t , tm = sqv.size();
816 for (t = 0; t < tm ; ++t)
817 for (i = 0; i < n ; ++i)
818 if ( temp[t].item( i ) <
_level)
825 for (t = 0; t < tm ; ++t)
826 for (i = 0; i < n ; ++i)
827 if ( temp[t].item( i ) <=
_level)
833 for (t = 0; t < tm ; ++t)
834 for (i = 0; i < n ; ++i)
835 if ( temp[t].item( i ) >
_level)
841 for (t = 0; t < tm ; ++t)
842 for (i = 0; i < n ; ++i)
843 if ( temp[t].item( i ) >=
_level)
849 for (t = 0; t < tm ; ++t)
850 for (i = 0; i < n ; ++i)
851 if ( temp[t].item( i ) ==
_level)
857 for (t = 0; t < tm ; ++t)
858 for (i = 0; i < n ; ++i)
859 if ( temp[t].item( i ) !=
_level)
865 for (t = 0; t < tm ; ++t)
866 for (i = 0; i < n ; ++i)
867 if ( temp[t].item( i ) >=
_level
868 && temp[t].item( i ) <=
_level2 )
874 for (t = 0; t < tm ; ++t)
875 for (i = 0; i < n ; ++i)
876 if ( temp[t].item( i ) >
_level
877 && temp[t].item( i ) <=
_level2 )
883 for (t = 0; t < tm ; ++t)
884 for (i = 0; i < n ; ++i)
885 if ( temp[t].item( i ) >=
_level
886 && temp[t].item( i ) <
_level2 )
892 for (t = 0; t < tm ; ++t)
893 for (i = 0; i < n ; ++i)
894 if ( temp[t].item( i ) >
_level
895 && temp[t].item( i ) <
_level2 )
901 for (t = 0; t < tm ; ++t)
902 for (i = 0; i < n ; ++i)
903 if ( temp[t].item( i ) <
_level
904 && temp[t].item( i ) >
_level2 )
910 for (t = 0; t < tm ; ++t)
911 for (i = 0; i < n ; ++i)
912 if ( temp[t].item( i ) <=
_level
913 && temp[t].item( i ) >
_level2 )
919 for (t = 0; t < tm ; ++t)
920 for (i = 0; i < n ; ++i)
921 if ( temp[t].item( i ) <
_level
922 && temp[t].item( i ) >=
_level2 )
928 for (t = 0; t < tm ; ++t)
929 for (i = 0; i < n ; ++i)
930 if ( temp[t].item( i ) <=
_level
931 && temp[t].item( i ) >=
_level2 )
TimeTexture< T > operator()(const TimeTexture< T > &sqv)
Return the multi-level thresholded texture.
virtual ~AimsTexThreshold()
threshold_t _type
Threshold type.
T _level
Lower level or unique level.
AimsTexThreshold(threshold_t type, T level, T level2=0, T backgd=0)
Texture thresholding.
TimeTexture< U > bin(const TimeTexture< T > &sqv)
Return the binary thresholded texture.
carto::VolumeRef< U > bin(const carto::VolumeRef< T > &sqv)
Return the binary thresholded image.
carto::VolumeRef< T > clip(const carto::VolumeRef< T > &sqv)
Return the multi-level thresholded image with clipped values (backgd ignored)
threshold_t _type
Threshold type.
carto::VolumeRef< T > operator()(const carto::VolumeRef< T > &sqv)
Return the multi-level thresholded image.
AimsThreshold(threshold_t type, T level, T level2=0, T backgd=0, U foregd=(U)(!std::numeric_limits< U >::is_specialized||(std::numeric_limits< U >::max() >=32767) ? 32767 :std::numeric_limits< U >::max()))
Volume thresholding.
T _level
Lower level or unique level.
void push_back(const T &item)
const T & item(int n) const
std::vector< int > getBorders() const
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
std::vector< float > getVoxelSize() const
virtual void copyHeaderFrom(const PropertySet &other)
std::vector< int > getSize() const
Volume< T >::iterator iterator
const PropertySet & header() const
Volume< T >::const_iterator const_iterator
Volume< OUTP > & applyTowards(const T &cst1, const Volume< U > &vol2, Volume< OUTP > &dst, BinaryFunction func)
bool operator()(const T &x, const T &y, const T &z) const
bool operator()(const T &x, const T &y, const T &z) const
bool operator()(const T &x, const T &y, const T &z) const
bool operator()(const T &x, const T &y, const T &z) const
LEFT operator()(const LEFT &x) const
clip2(LEFT threshold1, LEFT threshold2)
LEFT operator()(const LEFT &x) const
bool operator()(const T &x, const T &y, const T &z) const
bool operator()(const T &x, const T &y, const T &z) const
bool operator()(const T &x, const T &y, const T &z) const
bool operator()(const T &x, const T &y, const T &z) const
int operator()(const T &x, const T &y, const T &z) const
int operator()(const T &x, const T &y, const T &z) const
int operator()(const T &x, const T &y, const T &z) const
int operator()(const T &x, const T &y, const T &z) const
RIGHT operator()(const LEFT &x) const
thresh1_bin(LEFT threshold, RIGHT foreground)
thresh1(LEFT threshold, LEFT background)
LEFT operator()(const LEFT &x) const
thresh2_bin(LEFT threshold1, LEFT threshold2, RIGHT foreground)
RIGHT operator()(const LEFT &x) const
thresh2(LEFT threshold1, LEFT threshold2, LEFT background)
LEFT operator()(const LEFT &x) const
static const bool is_specialized
@ AIMS_GREATER_OR_EQUAL_TO
@ AIMS_OUTSIDE_INCLUDE_LOWER_BOUND
@ AIMS_BETWEEN_EXCLUDE_LOWER_BOUND
@ AIMS_OUTSIDE_INCLUDE_HIGHER_BOUND
@ AIMS_BETWEEN_EXCLUDE_HIGHER_BOUND
@ AIMS_BETWEEN_EXCLUDE_BOUNDS
@ AIMS_OUTSIDE_INCLUDE_BOUNDS