Image Component Library (ICL)
MorphologicalOp.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/MorphologicalOp.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 <ICLUtils/Uncopyable.h>
35 #include <ICLCore/Img.h>
37 
38 
39 namespace icl {
40  namespace filter{
41 
43 
88  public:
89 
91  enum optype {
92  dilate=0,
93  erode=1,
94  dilate3x3=2,
95  erode3x3=3,
96  dilateBorderReplicate=4,
97  erodeBorderReplicate=5,
98  openBorder=6,
99  closeBorder=7,
100  tophatBorder=8,
101  blackhatBorder=9,
102  gradientBorder=10
103  };
105 
114  MorphologicalOp (optype t, const utils::Size &maskSize=utils::Size(3,3), const icl8u *mask=0);
115 
117 
118  MorphologicalOp (const std::string &optype="erode", const utils::Size &maskSize=utils::Size(3,3), const icl8u *mask=0);
119 
121  ~MorphologicalOp ();
122 
124  void setMask (utils::Size size, const icl8u* pcMask=0);
125 
127 
130  const icl8u* getMask() const;
131 
133 
136  utils::Size getMaskSize() const;
137 
138  void setOptype(optype type);
139 
141 
144  optype getOptype() const;
145 
147  void apply (const core::ImgBase *poSrc, core::ImgBase **ppoDst);
148 
150  using UnaryOp::apply;
151 
152  #ifdef ICL_HAVE_IPP
153  private:
154 
155  template<typename T, IppStatus (IPP_DECL *ippiFunc) (const T*, int, T*, int, IppiSize, const Ipp8u*, IppiSize, IppiPoint)>
156  IppStatus ippiMorphologicalCall (const core::Img<T> *src, core::Img<T> *dst);
157  template<typename T, IppStatus (IPP_DECL *ippiFunc) (const T*, int, T*, int, IppiSize)>
158  IppStatus ippiMorphologicalCall3x3 (const core::Img<T> *src, core::Img<T> *dst);
159 
160  template<typename T, IppStatus (IPP_DECL *ippiFunc) (const T*, int, T*, int, IppiSize, _IppiBorderType, IppiMorphState*)>
161  IppStatus ippiMorphologicalBorderReplicateCall (const core::Img<T> *src, core::Img<T> *dst,IppiMorphState *state);
162 
163  template<typename T, IppStatus (IPP_DECL *ippiFunc) (const T*, int, T*, int, IppiSize, IppiBorderType, IppiMorphAdvState*)>
164  IppStatus ippiMorphologicalBorderCall (const core::Img<T> *src, core::Img<T> *dst, IppiMorphAdvState *advState);
165 
166  typedef IppiMorphState ICLMorphState ;
167  typedef IppiMorphAdvState ICLMorphAdvState;
168  #else
169  typedef void ICLMorphState;
170  typedef void ICLMorphAdvState;
171  core::ImgBase *m_openingAndClosingBuffer;
172  core::ImgBase *m_gradientBorderBuffer_1;
173  core::ImgBase *m_gradientBorderBuffer_2;
174 
175  private:
176  template<class T>
177  void apply_t(const core::ImgBase *src, core::ImgBase **dst);
178  #endif
179  private:
181  utils::Size m_oMaskSizeMorphOp; // actually masksize of NeighborhoodOp and MorphOp may be different
192  void deleteMorphStates();
193  void checkMorphAdvState8u(const utils::Size roiSize);
194  void checkMorphAdvState32f(const utils::Size roiSize);
195  void checkMorphState8u(const utils::Size roiSize);
196  void checkMorphState32f(const utils::Size roiSize);
197 
198 
200 
201  };
202  } // namespace filter
203 } // namespace icl
204 
optype m_eType
Definition: MorphologicalOp.h:199
undocument this line if you encounter any issues!
Definition: Any.h:37
Class interface for un-copyable classes.
Definition: Uncopyable.h:64
Ipp8u icl8u
8Bit unsigned integer type for the ICL
Definition: BasicTypes.h:64
ICLMorphAdvState * m_pAdvState8u
Definition: MorphologicalOp.h:184
optype
this enum specifiy all possible morphological operations
Definition: MorphologicalOp.h:91
bool m_bMorphState32f
Definition: MorphologicalOp.h:187
bool m_bMorphAdvState8u
Definition: MorphologicalOp.h:188
icl8u * m_pcMask
Definition: MorphologicalOp.h:180
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)
unary operators that work on each pixels neighborhood \
Definition: NeighborhoodOp.h:59
IppiMorphState ICLMorphState
Definition: MorphologicalOp.h:166
utils::Size m_oMaskSizeMorphOp
Definition: MorphologicalOp.h:181
bool m_bHas_changedAdv
Definition: MorphologicalOp.h:191
bool m_bMorphState8u
Definition: MorphologicalOp.h:186
ICLMorphAdvState * m_pAdvState32f
Definition: MorphologicalOp.h:185
#define ICLFilter_API
Definition: CompatMacros.h:175
Class for Morphological operations .
Definition: MorphologicalOp.h:87
bool m_bHas_changed
Definition: MorphologicalOp.h:190
ICLMorphState * m_pState32f
Definition: MorphologicalOp.h:183
IppiMorphAdvState ICLMorphAdvState
Definition: MorphologicalOp.h:167
virtual void apply(const core::ImgBase *operand1, core::ImgBase **dst)=0
pure virtual apply function, that must be implemented in all derived classes
ICLMorphState * m_pState8u
Definition: MorphologicalOp.h:182
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131
bool m_bMorphAdvState32f
Definition: MorphologicalOp.h:189