Image Component Library (ICL)
BinaryOp.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/BinaryOp.h **
10 ** Module : ICLFilter **
11 ** Authors: Christof Elbrechter, Andre Justus **
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/OpROIHandler.h>
35 
36 namespace icl{
37  namespace filter{
39 
43  public:
44 
46  BinaryOp();
47 
49  BinaryOp(const BinaryOp &other);
50 
52  BinaryOp &operator=(const BinaryOp &other);
53 
55  virtual ~BinaryOp();
56 
57 
59  virtual void apply(const core::ImgBase *operand1,const core::ImgBase *operand2, core::ImgBase **result)=0;
60 
62 
64  virtual const core::ImgBase *apply(const core::ImgBase *operand1, const core::ImgBase *operand2);
65 
67  inline void operator()(const core::ImgBase *src1,const core::ImgBase *src2, core::ImgBase **dst){
68  apply(src1,src2,dst);
69  }
70 
72  inline const core::ImgBase *operator()(const core::ImgBase *src1,const core::ImgBase *src2){
73  return apply(src1,src2);
74  }
75 
77  inline const core::ImgBase &operator()(const core::ImgBase &sr1,const core::ImgBase &src2){
78  return *apply(&sr1,&src2);
79  }
80 
82 
85  void setClipToROI (bool bClipToROI) { m_oROIHandler.setClipToROI(bClipToROI); }
86 
88 
91  void setCheckOnly (bool bCheckOnly) { m_oROIHandler.setCheckOnly(bCheckOnly); }
92 
94 
97  bool getClipToROI() const { return m_oROIHandler.getClipToROI(); }
98 
100 
103  bool getCheckOnly() const { return m_oROIHandler.getCheckOnly(); }
104 
105  protected:
106  bool prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize,
107  core::format eFormat, int nChannels, const utils::Rect& roi,
108  utils::Time timestamp=utils::Time::null){
109  return m_oROIHandler.prepare(ppoDst, eDepth,imgSize,eFormat, nChannels, roi, timestamp);
110  }
111 
113  virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc) {
114  return m_oROIHandler.prepare(ppoDst, poSrc);
115  }
116 
119  virtual bool prepare (core::ImgBase **ppoDst,
120  const core::ImgBase *poSrc,
121  core::depth eDepth) {
122  return m_oROIHandler.prepare(ppoDst, poSrc, eDepth);
123  }
124 
125  static inline bool check(const core::ImgBase *operand1,
126  const core::ImgBase *operand2 ,
127  bool checkDepths = true) {
128  if(!checkDepths) {
129  return operand1->getChannels() == operand2->getChannels() &&
130  operand1->getROISize() == operand2->getROISize() ;
131  } else {
132  return operand1->getChannels() == operand2->getChannels() &&
133  operand1->getROISize() == operand2->getROISize() &&
134  operand1->getDepth() == operand2->getDepth() ;
135  }
136  }
137 
138  private:
140 
143  };
144  } // namespace filter
145 }
146 
bool getCheckOnly() const
returns the CheckOnly status
Definition: BinaryOp.h:103
undocument this line if you encounter any issues!
Definition: Any.h:37
ICL Time class (taken from the Ice lib)
Definition: Time.h:52
ICLQt_API ImgROI roi(ImgQ &r)
creates a ROI-struct from an image
bool getClipToROI() const
returns the ClipToROI status
Definition: BinaryOp.h:97
depth getDepth() const
returns the depth (depth8u or depth32f)
Definition: ImgBase.h:492
Abstract base class for binary image operations.
Definition: BinaryOp.h:42
core::ImgBase * m_buf
internal image buffer which is used for the apply function without destination image argument
Definition: BinaryOp.h:142
virtual bool prepare(core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepth)
Definition: BinaryOp.h:119
format
determines the color-format, that is associated with the images channels
Definition: Types.h:70
void setCheckOnly(bool bCheckOnly)
sets if the destination image should be adapted to the source, or if it is only checked if it can be ...
Definition: BinaryOp.h:91
const core::ImgBase & operator()(const core::ImgBase &sr1, const core::ImgBase &src2)
reference based function operator
Definition: BinaryOp.h:77
bool prepare(core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize, core::format eFormat, int nChannels, const utils::Rect &roi, utils::Time timestamp=utils::Time::null)
Definition: BinaryOp.h:106
Size class of the ICL.
Definition: Size.h:61
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)
depth
determines the pixel type of an image (8Bit-int or 32Bit-float)
Definition: Types.h:60
utils::Size getROISize() const
returns the images ROI size
Definition: ImgBase.h:521
int getChannels() const
returns the channel count of the image
Definition: ImgBase.h:489
OpROIHandler m_oROIHandler
Definition: BinaryOp.h:139
#define ICLFilter_API
Definition: CompatMacros.h:175
virtual bool prepare(core::ImgBase **ppoDst, const core::ImgBase *poSrc)
check+adapt destination image to properties of given source image
Definition: BinaryOp.h:113
static bool check(const core::ImgBase *operand1, const core::ImgBase *operand2, bool checkDepths=true)
Definition: BinaryOp.h:125
const core::ImgBase * operator()(const core::ImgBase *src1, const core::ImgBase *src2)
function operator for the implicit destination apply(a,b) call
Definition: BinaryOp.h:72
Rectangle class of the ICL used e.g. for the Images ROI-rect.
Definition: Rect.h:95
static const Time null
Definition: Time.h:59
void operator()(const core::ImgBase *src1, const core::ImgBase *src2, core::ImgBase **dst)
function operator (alternative for apply(src1,src2,dst)
Definition: BinaryOp.h:67
void setClipToROI(bool bClipToROI)
sets if the image should be clip to ROI or not
Definition: BinaryOp.h:85
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131
Utility base class for Image Operators.
Definition: OpROIHandler.h:78