Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
UnaryCompareOp.h
Go to the documentation of this file.
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.LGPL **
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 <ICLUtils/CompatMacros.h>
00034 #include <ICLFilter/UnaryOp.h>
00035 
00036 namespace icl {
00037   namespace filter{
00038     
00040 
00045     class ICLFilter_API UnaryCompareOp : public UnaryOp {
00046       public:
00047    
00048   #ifdef ICL_HAVE_IPP
00049 
00050       enum optype{
00051         lt   = ippCmpLess,      
00052         lteq = ippCmpLessEq,    
00053         eq   = ippCmpEq,        
00054         gteq = ippCmpGreaterEq, 
00055         gt   = ippCmpGreater,   
00056         eqt                     
00057       };
00058   #else
00059 
00060       enum optype{
00061         lt,   
00062         lteq, 
00063         eq,   
00064         gteq, 
00065         gt,   
00066         eqt   
00067       };
00068   #endif
00069       
00071 
00078       static optype translate_op_type(const std::string &stringVersion) throw (utils::ICLException){
00079         if(stringVersion == "<") return UnaryCompareOp::lt;
00080         if(stringVersion == ">") return UnaryCompareOp::gt;
00081         if(stringVersion == "<=") return UnaryCompareOp::lteq;
00082         if(stringVersion == ">=") return UnaryCompareOp::gteq;
00083         if(stringVersion == "==") return UnaryCompareOp::eq;
00084         if(stringVersion == " ~=") return UnaryCompareOp::eqt;
00085         throw utils::ICLException("UnaryCompareOp::translate_op_type(" + stringVersion + "): invalid optype string!");
00087         return UnaryCompareOp::lt;
00088       }
00089       
00091 
00095       UnaryCompareOp(optype ot=gt, icl64f value=128, icl64f tolerance=0):
00096       m_eOpType(ot), m_dValue(value), m_dTolerance(tolerance){ }
00097   
00099 
00101       UnaryCompareOp(const std::string &op, icl64f value=128, icl64f tolerance=0):
00102       m_eOpType(translate_op_type(op)), m_dValue(value), m_dTolerance(tolerance){ }
00103       
00105       virtual ~UnaryCompareOp(){}
00106       
00108 
00109       void setOpType(optype ot){ m_eOpType = ot; }
00110   
00112 
00113       void setValue(icl64f value){ m_dValue = value; }
00114       
00116 
00117       void setTollerance(icl64f tolerance){ m_dTolerance = tolerance; }
00118       
00120       optype getOpType() const { return m_eOpType; }
00121       
00123 
00124       icl64f getValue() const { return m_dValue; }
00125   
00127 
00128       icl64f getTolerance() const { return m_dTolerance; }
00129       
00131 
00134       virtual void apply(const core::ImgBase *poSrc, core::ImgBase **ppoDst);
00135       
00137       using UnaryOp::apply;
00138       private:
00139       
00141       optype m_eOpType;
00142       
00144       icl64f m_dValue;
00145   
00147       icl64f m_dTolerance;
00148     };
00149   } // namespace filter
00150 } // namespace icl
00151 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines