Image Component Library (ICL)
UnaryCompareOp.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLFilter/src/ICLFilter/UnaryCompareOp.h **
10 ** Module : ICLFilter **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLFilter/UnaryOp.h>
35 
36 namespace icl {
37  namespace filter{
38 
40 
46  public:
47 
48  #ifdef ICL_HAVE_IPP
49  enum optype{
51  lt = ippCmpLess,
52  lteq = ippCmpLessEq,
53  eq = ippCmpEq,
54  gteq = ippCmpGreaterEq,
55  gt = ippCmpGreater,
56  eqt
57  };
58  #else
59  enum optype{
61  lt,
62  lteq,
63  eq,
64  gteq,
65  gt,
66  eqt
67  };
68  #endif
69 
71 
78  static optype translate_op_type(const std::string &stringVersion) {
79  if(stringVersion == "<") return UnaryCompareOp::lt;
80  if(stringVersion == ">") return UnaryCompareOp::gt;
81  if(stringVersion == "<=") return UnaryCompareOp::lteq;
82  if(stringVersion == ">=") return UnaryCompareOp::gteq;
83  if(stringVersion == "==") return UnaryCompareOp::eq;
84  if(stringVersion == " ~=") return UnaryCompareOp::eqt;
85  throw utils::ICLException("UnaryCompareOp::translate_op_type(" + stringVersion + "): invalid optype string!");
87  return UnaryCompareOp::lt;
88  }
89 
91 
95  UnaryCompareOp(optype ot=gt, icl64f value=128, icl64f tolerance=0):
96  m_eOpType(ot), m_dValue(value), m_dTolerance(tolerance){ }
97 
99 
101  UnaryCompareOp(const std::string &op, icl64f value=128, icl64f tolerance=0):
102  m_eOpType(translate_op_type(op)), m_dValue(value), m_dTolerance(tolerance){ }
103 
105  virtual ~UnaryCompareOp(){}
106 
108 
109  void setOpType(optype ot){ m_eOpType = ot; }
110 
112 
113  void setValue(icl64f value){ m_dValue = value; }
114 
116 
117  void setTollerance(icl64f tolerance){ m_dTolerance = tolerance; }
118 
120  optype getOpType() const { return m_eOpType; }
121 
123 
124  icl64f getValue() const { return m_dValue; }
125 
127 
128  icl64f getTolerance() const { return m_dTolerance; }
129 
131 
134  virtual void apply(const core::ImgBase *poSrc, core::ImgBase **ppoDst);
135 
137  using UnaryOp::apply;
138  private:
139 
142 
145 
148  };
149  } // namespace filter
150 } // namespace icl
151 
optype
this enum specifiy all possible compare operations
Definition: UnaryCompareOp.h:50
Definition: UnaryCompareOp.h:56
icl64f m_dTolerance
internal storage of the current tolerance level
Definition: UnaryCompareOp.h:147
void setOpType(optype ot)
sets the current optype
Definition: UnaryCompareOp.h:109
undocument this line if you encounter any issues!
Definition: Any.h:37
Definition: UnaryCompareOp.h:52
Definition: UnaryCompareOp.h:55
UnaryCompareOp(optype ot=gt, icl64f value=128, icl64f tolerance=0)
Creates a new UnaryCompareOp object with given optype, value and tolerance level.
Definition: UnaryCompareOp.h:95
Definition: UnaryCompareOp.h:53
Definition: UnaryCompareOp.h:51
icl64f m_dValue
internal storage of the current value
Definition: UnaryCompareOp.h:144
static optype translate_op_type(const std::string &stringVersion)
translate a given relation into an optype
Definition: UnaryCompareOp.h:78
optype m_eOpType
internal storage of the current optype
Definition: UnaryCompareOp.h:141
Ipp64f icl64f
64Bit floating point type for the ICL
Definition: BasicTypes.h:52
optype getOpType() const
returns the current optype
Definition: UnaryCompareOp.h:120
Abstract Base class for Unary Operators.
Definition: UnaryOp.h:51
ICLQt_API core::Img< T > filter(const core::Img< T > &image, const std::string &filter)
applies a filter operation on the source image (affinity for float)
UnaryCompareOp(const std::string &op, icl64f value=128, icl64f tolerance=0)
creates a new UnaryCompareOp instance with given parameters
Definition: UnaryCompareOp.h:101
icl64f getTolerance() const
returns the current tolerance level
Definition: UnaryCompareOp.h:128
Class for comparing operations.
Definition: UnaryCompareOp.h:45
Base class for Exception handling in the ICL.
Definition: Exception.h:42
#define ICLFilter_API
Definition: CompatMacros.h:175
void setValue(icl64f value)
sets the current compare value
Definition: UnaryCompareOp.h:113
virtual void apply(const core::ImgBase *operand1, core::ImgBase **dst)=0
pure virtual apply function, that must be implemented in all derived classes
virtual ~UnaryCompareOp()
Destructor.
Definition: UnaryCompareOp.h:105
icl64f getValue() const
returns the current compare-value
Definition: UnaryCompareOp.h:124
Definition: UnaryCompareOp.h:54
void setTollerance(icl64f tolerance)
sets the current tolerance level
Definition: UnaryCompareOp.h:117
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131