Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
BinaryOp.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/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.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/OpROIHandler.h>
00034 
00035 namespace icl{
00036   namespace filter{
00038 
00041     class BinaryOp{
00042       public:
00043       
00045       BinaryOp();
00046       
00048       BinaryOp(const BinaryOp &other);
00049       
00051       BinaryOp &operator=(const BinaryOp &other);
00052       
00054       virtual ~BinaryOp();
00055       
00056       
00058       virtual void apply(const core::ImgBase *operand1,const core::ImgBase *operand2, core::ImgBase **result)=0;
00059       
00061 
00063       virtual const core::ImgBase *apply(const core::ImgBase *operand1, const core::ImgBase *operand2);
00064       
00066       inline void operator()(const core::ImgBase *src1,const core::ImgBase *src2, core::ImgBase **dst){
00067         apply(src1,src2,dst);
00068       }
00069 
00071       inline const core::ImgBase *operator()(const core::ImgBase *src1,const core::ImgBase *src2){
00072         return apply(src1,src2);
00073       }
00074 
00076       inline const core::ImgBase &operator()(const core::ImgBase &sr1,const core::ImgBase &src2){
00077         return *apply(&sr1,&src2);
00078       }
00079   
00081 
00084       void setClipToROI (bool bClipToROI) { m_oROIHandler.setClipToROI(bClipToROI); }
00085   
00087 
00090       void setCheckOnly (bool bCheckOnly) { m_oROIHandler.setCheckOnly(bCheckOnly); }
00091       
00093 
00096       bool getClipToROI() const { return m_oROIHandler.getClipToROI(); }
00097       
00099 
00102       bool getCheckOnly() const { return m_oROIHandler.getCheckOnly(); }
00103   
00104       protected:
00105       bool prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize, 
00106                     core::format eFormat, int nChannels, const utils::Rect& roi, 
00107                     utils::Time timestamp=utils::Time::null){
00108         return m_oROIHandler.prepare(ppoDst, eDepth,imgSize,eFormat, nChannels, roi, timestamp);
00109       }
00110       
00112       virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc) {
00113         return m_oROIHandler.prepare(ppoDst, poSrc);
00114       }
00115       
00118       virtual bool prepare (core::ImgBase **ppoDst, 
00119                             const core::ImgBase *poSrc, 
00120                             core::depth eDepth) {
00121         return m_oROIHandler.prepare(ppoDst, poSrc, eDepth);
00122       }
00123       
00124       static inline bool check(const core::ImgBase *operand1,
00125                                const core::ImgBase *operand2 , 
00126                                bool checkDepths = true) {
00127         if(!checkDepths) {
00128           return operand1->getChannels() == operand2->getChannels() &&
00129             operand1->getROISize() == operand2->getROISize() ;
00130         } else {
00131           return operand1->getChannels() == operand2->getChannels() &&
00132             operand1->getROISize() == operand2->getROISize() &&
00133             operand1->getDepth() == operand2->getDepth() ;
00134         }            
00135       }
00136       
00137     private:
00138       OpROIHandler m_oROIHandler;
00139   
00141       core::ImgBase *m_buf;
00142     };
00143   } // namespace filter
00144 }
00145 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines