37 #ifndef AIMS_UTILITY_THRESHOLD_H 
   38 #define AIMS_UTILITY_THRESHOLD_H 
   92 template <
class T,
class U>
 
  129 template <
class T,
class U>
 
  157 template <
class T,
class U> 
inline 
  160   : _type( type ), _level( level ), _level2( level2 ), _backgd( backgd ), _foregd( foregd )
 
  164 template <
class T,
class U> 
inline 
  167   : _type( type ), _level( level ), _level2( level2 ), _backgd( backgd )
 
  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>
 
  294 template <
class T,
class U> 
inline 
  342           _level, _level2, _backgd ) );
 
  348           _level, _level2, _backgd ) );
 
  354           _level, _level2, _backgd ) );
 
  360           _level, _level2, _backgd ) );
 
  366           _level, _level2, _backgd ) );
 
  372           _level, _level2, _backgd ) );
 
  378           _level, _level2, _backgd ) );
 
  384           _level, _level2, _backgd ) );
 
  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>
 
  489 template <
class T,
class U> 
inline 
  553       std::cerr << 
"Warning: AimsThreshold cannot use clipping with this mode, " 
  554         "using standard clipping instead." << std::endl;
 
  562 template <
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)
 
  573             res.
item( i )  = ( res[t].
item( i ) < _level ? res[t].
item( i ) 
 
  577       for (t = 0; t < tm ; ++t)
 
  578         for (i = 0; i < n ; ++i)
 
  579           res.
item( i )  = ( res[t].
item( i ) <= _level ?  res[t].
item( i ) 
 
  583       for (t = 0; t < tm ; ++t)
 
  584         for (i = 0; i < n ; ++i)
 
  585           res.
item( i )  = ( res[t].
item( i ) > _level ?  res[t].
item( i ) 
 
  589       for (t = 0; t < tm ; ++t)
 
  590         for (i = 0; i < n ; ++i)
 
  591           res.
item( i )  = ( res[t].
item( i ) >= _level ?  res[t].
item( i ) 
 
  595       for (t = 0; t < tm ; ++t)
 
  596         for (i = 0; i < n ; ++i)
 
  597           res.
item( i )  = ( res[t].
item( i ) == _level ?  res[t].
item( i ) 
 
  601       for (t = 0; t < tm ; ++t)
 
  602         for (i = 0; i < n ; ++i)
 
  603           res.
item( i )  = ( res[t].
item( i ) != _level ?  res[t].
item( i ) 
 
  607       for (t = 0; t < tm ; ++t)
 
  608         for (i = 0; i < n ; ++i)
 
  609           res.
item( i )  = ( res[t].
item( i ) >= _level && res[t].
item( i ) 
 
  610                              <= _level2 ?  res[t].
item( i ) : _backgd);
 
  613       for (t = 0; t < tm ; ++t)
 
  614         for (i = 0; i < n ; ++i)
 
  615           res.
item( i )  = ( res[t].
item( i ) > _level && res[t].
item( i ) 
 
  616                              <= _level2 ?  res[t].
item( i ) : _backgd);
 
  619       for (t = 0; t < tm ; ++t)
 
  620         for (i = 0; i < n ; ++i)
 
  621           res.
item( i )  = ( res[t].
item( i ) > _level && res[t].
item( i ) 
 
  622                              < _level2 ?  res[t].
item( i ) : _backgd);
 
  625       for (t = 0; t < tm ; ++t)
 
  626         for (i = 0; i < n ; ++i)
 
  627           res.
item( i )  = ( res[t].
item( i ) > _level && res[t].
item( i ) 
 
  628                              < _level2 ?  res[t].
item( i ) : _backgd);
 
  631       for (t = 0; t < tm ; ++t)
 
  632         for (i = 0; i < n ; ++i)
 
  633           res.
item( i )  = ( res[t].
item( i ) < _level || res[t].
item( i ) 
 
  634                              > _level2 ? (U) res[t].item( i ) : _backgd);
 
  637       for (t = 0; t < tm ; ++t)
 
  638         for (i = 0; i < n ; ++i)
 
  639           res.
item( i )  = ( res[t].
item( i ) <= _level || res[t].
item( i ) 
 
  640                              > _level2 ? (U) res[t].item( i ) : _backgd);
 
  643       for (t = 0; t < tm ; ++t)
 
  644         for (i = 0; i < n ; ++i)
 
  645           res.
item( i )  = ( res[t].
item( i ) < _level || res[t].
item( i ) 
 
  646                              >= _level2 ? (U) res[t].item( i ) : _backgd);
 
  649       for (t = 0; t < tm ; ++t)
 
  650         for (i = 0; i < n ; ++i)
 
  651           res.
item( i )  = ( res[t].
item( i ) <= _level || res[t].
item( i ) 
 
  652                              >= _level2 ? (U) res[t].item( i ) : _backgd);
 
  663   template <
typename LEFT, 
typename RIGHT, 
typename OP>
 
  682   template <
typename LEFT, 
typename RIGHT, 
typename OP>
 
  703 template <
class T,
class U> 
inline 
  757           _level, _level2, _foregd ) );
 
  763           _level, _level2, _foregd ) );
 
  769           _level, _level2, _foregd ) );
 
  775           _level, _level2, _foregd ) );
 
  781           _level, _level2, _foregd ) );
 
  787           _level, _level2, _foregd ) );
 
  793           _level, _level2, _foregd ) );
 
  799           _level, _level2, _foregd ) );
 
  807 template <
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.
The template class to make thresholds.
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
@ 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