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/BinaryOp.h ** 00010 ** Module : ICLFilter ** 00011 ** Authors: Christof Elbrechter, Andre Justus ** 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/OpROIHandler.h> 00035 00036 namespace icl{ 00037 namespace filter{ 00039 00042 class ICLFilter_API BinaryOp{ 00043 public: 00044 00046 BinaryOp(); 00047 00049 BinaryOp(const BinaryOp &other); 00050 00052 BinaryOp &operator=(const BinaryOp &other); 00053 00055 virtual ~BinaryOp(); 00056 00057 00059 virtual void apply(const core::ImgBase *operand1,const core::ImgBase *operand2, core::ImgBase **result)=0; 00060 00062 00064 virtual const core::ImgBase *apply(const core::ImgBase *operand1, const core::ImgBase *operand2); 00065 00067 inline void operator()(const core::ImgBase *src1,const core::ImgBase *src2, core::ImgBase **dst){ 00068 apply(src1,src2,dst); 00069 } 00070 00072 inline const core::ImgBase *operator()(const core::ImgBase *src1,const core::ImgBase *src2){ 00073 return apply(src1,src2); 00074 } 00075 00077 inline const core::ImgBase &operator()(const core::ImgBase &sr1,const core::ImgBase &src2){ 00078 return *apply(&sr1,&src2); 00079 } 00080 00082 00085 void setClipToROI (bool bClipToROI) { m_oROIHandler.setClipToROI(bClipToROI); } 00086 00088 00091 void setCheckOnly (bool bCheckOnly) { m_oROIHandler.setCheckOnly(bCheckOnly); } 00092 00094 00097 bool getClipToROI() const { return m_oROIHandler.getClipToROI(); } 00098 00100 00103 bool getCheckOnly() const { return m_oROIHandler.getCheckOnly(); } 00104 00105 protected: 00106 bool prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize, 00107 core::format eFormat, int nChannels, const utils::Rect& roi, 00108 utils::Time timestamp=utils::Time::null){ 00109 return m_oROIHandler.prepare(ppoDst, eDepth,imgSize,eFormat, nChannels, roi, timestamp); 00110 } 00111 00113 virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc) { 00114 return m_oROIHandler.prepare(ppoDst, poSrc); 00115 } 00116 00119 virtual bool prepare (core::ImgBase **ppoDst, 00120 const core::ImgBase *poSrc, 00121 core::depth eDepth) { 00122 return m_oROIHandler.prepare(ppoDst, poSrc, eDepth); 00123 } 00124 00125 static inline bool check(const core::ImgBase *operand1, 00126 const core::ImgBase *operand2 , 00127 bool checkDepths = true) { 00128 if(!checkDepths) { 00129 return operand1->getChannels() == operand2->getChannels() && 00130 operand1->getROISize() == operand2->getROISize() ; 00131 } else { 00132 return operand1->getChannels() == operand2->getChannels() && 00133 operand1->getROISize() == operand2->getROISize() && 00134 operand1->getDepth() == operand2->getDepth() ; 00135 } 00136 } 00137 00138 private: 00139 OpROIHandler m_oROIHandler; 00140 00142 core::ImgBase *m_buf; 00143 }; 00144 } // namespace filter 00145 } 00146