Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLFilter/src/ICLFilter/UnaryCompareOp.h ** 00010 ** Module : ICLFilter ** 00011 ** Authors: Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.GPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLFilter/UnaryOp.h> 00034 00035 namespace icl { 00036 namespace filter{ 00037 00039 00044 class UnaryCompareOp : public UnaryOp { 00045 public: 00046 00047 #ifdef HAVE_IPP 00048 00049 enum optype{ 00050 lt = ippCmpLess, 00051 lteq = ippCmpLessEq, 00052 eq = ippCmpEq, 00053 gteq = ippCmpGreaterEq, 00054 gt = ippCmpGreater, 00055 eqt 00056 }; 00057 #else 00058 00059 enum optype{ 00060 lt, 00061 lteq, 00062 eq, 00063 gteq, 00064 gt, 00065 eqt 00066 }; 00067 #endif 00068 00070 00077 static optype translate_op_type(const std::string &stringVersion) throw (utils::ICLException){ 00078 if(stringVersion == "<") return UnaryCompareOp::lt; 00079 if(stringVersion == ">") return UnaryCompareOp::gt; 00080 if(stringVersion == "<=") return UnaryCompareOp::lteq; 00081 if(stringVersion == ">=") return UnaryCompareOp::gteq; 00082 if(stringVersion == "==") return UnaryCompareOp::eq; 00083 if(stringVersion == " ~=") return UnaryCompareOp::eqt; 00084 throw utils::ICLException("UnaryCompareOp::translate_op_type(" + stringVersion + "): invalid optype string!"); 00086 return UnaryCompareOp::lt; 00087 } 00088 00090 00094 UnaryCompareOp(optype ot=gt, icl64f value=128, icl64f tolerance=0): 00095 m_eOpType(ot), m_dValue(value), m_dTolerance(tolerance){ } 00096 00098 00100 UnaryCompareOp(const std::string &op, icl64f value=128, icl64f tolerance=0): 00101 m_eOpType(translate_op_type(op)), m_dValue(value), m_dTolerance(tolerance){ } 00102 00104 virtual ~UnaryCompareOp(){} 00105 00107 00108 void setOpType(optype ot){ m_eOpType = ot; } 00109 00111 00112 void setValue(icl64f value){ m_dValue = value; } 00113 00115 00116 void setTollerance(icl64f tolerance){ m_dTolerance = tolerance; } 00117 00119 optype getOpType() const { return m_eOpType; } 00120 00122 00123 icl64f getValue() const { return m_dValue; } 00124 00126 00127 icl64f getTolerance() const { return m_dTolerance; } 00128 00130 00133 virtual void apply(const core::ImgBase *poSrc, core::ImgBase **ppoDst); 00134 00136 using UnaryOp::apply; 00137 private: 00138 00140 optype m_eOpType; 00141 00143 icl64f m_dValue; 00144 00146 icl64f m_dTolerance; 00147 }; 00148 } // namespace filter 00149 } // namespace icl 00150