Image Component Library (ICL)
UnaryOp.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/UnaryOp.h **
10 ** Module : ICLFilter **
11 ** Authors: Christof Elbrechter **
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 <ICLUtils/Configurable.h>
35 #include <ICLFilter/OpROIHandler.h>
36 
37 namespace icl{
39  namespace utils{
40  class MultiThreader;
41  }
44  namespace filter{
45 
46 
48 
52  void initConfigurable();
53 
54  public:
55 
57  UnaryOp();
58 
60  UnaryOp(const UnaryOp &other);
61 
63  UnaryOp &operator=(const UnaryOp &other);
64 
65 
67  virtual ~UnaryOp();
68 
70  virtual void apply(const core::ImgBase *operand1, core::ImgBase **dst)=0;
71 
73  virtual ICL_DEPRECATED void applyMT(const core::ImgBase *operand1,
74  core::ImgBase **dst, unsigned int nThreads);
75 
77 
80  virtual const core::ImgBase *apply(const core::ImgBase *src);
81 
83  inline void operator()(const core::ImgBase *src, core::ImgBase **dst){
84  apply(src,dst);
85  }
86 
88  inline const core::ImgBase *operator()(const core::ImgBase *src){
89  return apply(src);
90  }
91 
93  inline const core::ImgBase &operator()(const core::ImgBase &src){
94  return *apply(&src);
95  }
96 
97 
99 
102  void setClipToROI (bool bClipToROI) {
103  m_oROIHandler.setClipToROI(bClipToROI);
104  prop("UnaryOp.clip to ROI").value = bClipToROI ? "on" : "off";
105  call_callbacks("UnaryOp.clip to ROI",this);
106  }
107 
109 
112  void setCheckOnly (bool bCheckOnly) {
113  m_oROIHandler.setCheckOnly(bCheckOnly);
114  prop("UnaryOp.check only").value = bCheckOnly ? "on" : "off";
115  call_callbacks("UnaryOp.check only",this);
116  }
117 
119 
122  bool getClipToROI() const { return m_oROIHandler.getClipToROI(); }
123 
125 
128  bool getCheckOnly() const { return m_oROIHandler.getCheckOnly(); }
129 
130 
132  virtual void setPropertyValue(const std::string &propertyName, const utils::Any &value) ;
133 
135 
147  static UnaryOp *fromString(const std::string &definition) ;
148 
150 
151  static std::string getFromStringSyntax(const std::string &opSpecifier) ;
152 
154  static std::vector<std::string> listFromStringOps();
155 
157  static void applyFromString(const std::string &definition,
158  const core::ImgBase *src,
159  core::ImgBase **dst) ;
160 
161  protected:
162  bool prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize,
163  core::format eFormat, int nChannels, const utils::Rect& roi,
164  utils::Time timestamp=utils::Time::null){
165  return m_oROIHandler.prepare(ppoDst, eDepth,imgSize,eFormat, nChannels, roi, timestamp);
166  }
167 
169  virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc) {
170  return m_oROIHandler.prepare(ppoDst, poSrc);
171  }
172 
175  virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepth) {
176  return m_oROIHandler.prepare(ppoDst, poSrc, eDepth);
177  }
178 
180 
181  private:
182 
184 
186  };
187 
188 
189  #define DYNAMIC_UNARY_OP_CREATION_FUNCTION(NAME) \
190  extern "C" { \
191  UnaryOp *create_##NAME(const std::string &s){ \
192  return NAME(s); \
193  } \
194  }
195 
196  } // namespace filter
197 }
198 
199 
const core::ImgBase & operator()(const core::ImgBase &src)
reference based function operator
Definition: UnaryOp.h:93
OpROIHandler m_oROIHandler
Definition: UnaryOp.h:183
utils::MultiThreader * m_poMT
Definition: UnaryOp.h:179
undocument this line if you encounter any issues!
Definition: Any.h:37
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: UnaryOp.h:162
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
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: UnaryOp.h:112
Utility class for parallelizing algorithms.
Definition: MultiThreader.h:161
const core::ImgBase * operator()(const core::ImgBase *src)
function operator for the implicit destination apply(src) call
Definition: UnaryOp.h:88
format
determines the color-format, that is associated with the images channels
Definition: Types.h:70
bool getCheckOnly() const
returns the CheckOnly status
Definition: UnaryOp.h:128
void setClipToROI(bool bClipToROI)
sets if the image should be clip to ROI or not
Definition: UnaryOp.h:102
Abstract Base class for Unary Operators.
Definition: UnaryOp.h:51
Size class of the ICL.
Definition: Size.h:61
#define ICL_DEPRECATED
Definition: Macros.h:249
virtual bool prepare(core::ImgBase **ppoDst, const core::ImgBase *poSrc)
check+adapt destination image to properties of given source image
Definition: UnaryOp.h:169
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
core::ImgBase * m_buf
Definition: UnaryOp.h:185
Interface for classes that can be configured from configuration-files and GUI-Components.
Definition: Configurable.h:194
bool getClipToROI() const
returns the ClipToROI status
Definition: UnaryOp.h:122
#define ICLFilter_API
Definition: CompatMacros.h:175
virtual bool prepare(core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepth)
Definition: UnaryOp.h:175
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
Simple generic data type implementation that uses a string based data representation.
Definition: Any.h:109
void operator()(const core::ImgBase *src, core::ImgBase **dst)
function operator (alternative for apply(src,dst)
Definition: UnaryOp.h:83
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