28 namespace ost {
namespace img {
namespace alg {
39 bool bigger<Complex>(
Complex& v,
Real rv,
const Complex& cv) {
return std::abs(v)>=std::abs(cv);}
44 return static_cast<Real>(v)>=rv;
48 explicit ThresholdFnc(): r_fv_(0.0) { set_rval(0.0); }
49 explicit ThresholdFnc(
Real f) {set_rval(f);}
50 explicit ThresholdFnc(
const Complex& f) {set_cval(f);}
52 void SetThreshold(
Real f) {set_rval(f);}
53 void SetThreshold(
const Complex& f) {set_cval(f);}
55 template <
typename T,
class D>
56 void VisitState(ImageStateImpl<T,D>& isi)
const {
57 static const T zero=T();
58 static const T one=T(1);
59 for(T* p = isi.Data().GetData(); p<isi.Data().GetEnd();++p) {
60 (*p)= bigger<T>(*p,r_fv_,c_fv_)? one : zero ;
64 static String GetAlgorithmName() {
return "Threshold";}
70 void set_rval(
Real f) {r_fv_=f; c_fv_=Val2Val<Real,Complex>(f);}
in-place modifying image state const visitor plus ip algorithm
in-place modifying image state visitor plus ip algorithm
#define OST_IMG_ALG_EXPLICIT_INST_DECL(c, t)
std::complex< Real > Complex
ImageStateConstModIPAlgorithm< ThresholdFnc > Threshold
Real Val2Val< Complex, Real >(const Complex &c)