Image Component Library (ICL)
OpROIHandler.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/OpROIHandler.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 <ICLCore/ImgBase.h>
35 
36 namespace icl {
37  namespace filter{
39 
79  public:
81  virtual ~OpROIHandler(){}
82 
83 
84  private:
85  friend class UnaryOp;
86  friend class BinaryOp;
88  void setClipToROI (bool bClipToROI) {this->m_bClipToROI = bClipToROI;}
89  void setCheckOnly (bool bCheckOnly) {this->m_bCheckOnly = bCheckOnly;}
90 
91  bool getClipToROI() const { return m_bClipToROI; }
92  bool getCheckOnly() const { return m_bCheckOnly; }
93 
95  OpROIHandler() : m_bClipToROI (true), m_bCheckOnly (false) {}
96 
99  bool prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize,
100  core::format eFormat, int nChannels, const utils::Rect& roi,
101  utils::Time timestamp=utils::Time::null);
102 
104  virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc) {
105  // ensure that the checkOnly flag is set to TRUE, if source and destination images are the same pointers,
106  // this can not lead to problems, because *ppoDst is reallocated only if its depth differs from
107  // the source images depth (which is not true if poSrc==*ppoDst
108  //ICLASSERT_RETURN_VAL( !(ppoDst && (*ppoDst==poSrc) && !getCheckOnly() ), false);
109  return prepare (ppoDst, poSrc->getDepth(), chooseSize (poSrc),
110  poSrc->getFormat(), poSrc->getChannels (), chooseROI (poSrc),
111  poSrc->getTime());
112  }
113 
116  virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepth) {
117  // ensure that the checkOnly flag is set to TRUE, if source and destination images are the same pointers,
118  // this can not lead to problems, because *ppoDst is reallocated only if its depth differs from
119  // the source images depth (which is not true if poSrc==*ppoDst
120  // ICLASSERT_RETURN_VAL( !(ppoDst && (*ppoDst==poSrc) && !getCheckOnly() ), false);
121  return prepare (ppoDst, eDepth, chooseSize (poSrc),
122  poSrc->getFormat(), poSrc->getChannels (), chooseROI (poSrc),
123  poSrc->getTime());
124  }
126  const utils::Size chooseSize (const core::ImgBase *poSrc) {
127  return m_bClipToROI ? poSrc->getROISize () : poSrc->getSize ();
128  }
130  const utils::Rect chooseROI (const core::ImgBase *poSrc) {
131  return m_bClipToROI ? utils::Rect (utils::Point::null, poSrc->getROISize ())
132  : poSrc->getROI();
133  }
134 
135  bool m_bClipToROI, m_bCheckOnly;
136  };
137  } // namespace filter
138 }
format getFormat() const
returns the current (color)-format of this image
Definition: ImgBase.h:495
void setClipToROI(bool bClipToROI)
change adaption of destination image (see class description)
Definition: OpROIHandler.h:88
undocument this line if you encounter any issues!
Definition: Any.h:37
ICL Time class (taken from the Ice lib)
Definition: Time.h:52
virtual ~OpROIHandler()
Destructor.
Definition: OpROIHandler.h:81
ICLQt_API ImgROI roi(ImgQ &r)
creates a ROI-struct from an image
const utils::Rect chooseROI(const core::ImgBase *poSrc)
return to-be-used ROI depending on bClipToROI
Definition: OpROIHandler.h:130
depth getDepth() const
returns the depth (depth8u or depth32f)
Definition: ImgBase.h:492
Abstract base class for binary image operations.
Definition: BinaryOp.h:42
void setCheckOnly(bool bCheckOnly)
Definition: OpROIHandler.h:89
const utils::Rect & getROI() const
returns the images ROI rectangle
Definition: ImgBase.h:512
virtual bool prepare(core::ImgBase **ppoDst, const core::ImgBase *poSrc)
check+adapt destination image to properties of given source image
Definition: OpROIHandler.h:104
format
determines the color-format, that is associated with the images channels
Definition: Types.h:70
const utils::Size chooseSize(const core::ImgBase *poSrc)
return to-be-used image size depending on bClipToROI
Definition: OpROIHandler.h:126
bool m_bClipToROI
Definition: OpROIHandler.h:135
Abstract Base class for Unary Operators.
Definition: UnaryOp.h:51
Size class of the ICL.
Definition: Size.h:61
OpROIHandler()
Filter is a base class for other classes and should be instantiated.
Definition: OpROIHandler.h:95
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
static const Point null
null Point is x=0, y=0
Definition: Point.h:61
virtual bool prepare(core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepth)
Definition: OpROIHandler.h:116
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
#define ICLFilter_API
Definition: CompatMacros.h:175
Rectangle class of the ICL used e.g. for the Images ROI-rect.
Definition: Rect.h:95
utils::Time getTime() const
returns the timestamp of the image
Definition: ImgBase.h:498
static const Time null
Definition: Time.h:59
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
const utils::Size & getSize() const
returns the size of the images
Definition: ImgBase.h:477
bool getCheckOnly() const
Definition: OpROIHandler.h:92
bool getClipToROI() const
Definition: OpROIHandler.h:91