Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MorphologicalOp.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/MorphologicalOp.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.LGPL **
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 <ICLUtils/CompatMacros.h>
00034 #include <ICLUtils/Uncopyable.h>
00035 #include <ICLCore/Img.h>
00036 #include <ICLFilter/NeighborhoodOp.h>
00037 
00038 
00039 namespace icl {
00040   namespace filter{
00041     
00043 
00087     class ICLFilter_API MorphologicalOp : public NeighborhoodOp, public utils::Uncopyable {
00088     public:
00089   
00091     enum optype { 
00092       dilate=0,
00093       erode=1,
00094       dilate3x3=2,
00095       erode3x3=3,
00096       dilateBorderReplicate=4,
00097       erodeBorderReplicate=5,
00098       openBorder=6,
00099       closeBorder=7,
00100       tophatBorder=8,
00101       blackhatBorder=9,
00102       gradientBorder=10
00103     };
00105 
00114     MorphologicalOp (optype t, const utils::Size &maskSize=utils::Size(3,3), const icl8u *mask=0);
00115 
00117 
00118     MorphologicalOp (const std::string &optype="erode", const utils::Size &maskSize=utils::Size(3,3), const icl8u *mask=0);
00119       
00121       ~MorphologicalOp ();
00122     
00124       void setMask (utils::Size size, const icl8u* pcMask=0);
00125       
00127 
00130       const icl8u* getMask() const;
00131   
00133 
00136       utils::Size getMaskSize() const;
00137       
00138       void setOptype(optype type);
00139       
00141 
00144       optype getOptype() const;
00145       
00147       void apply (const core::ImgBase *poSrc, core::ImgBase **ppoDst);
00148       
00150       using UnaryOp::apply;
00151       
00152   #ifdef ICL_HAVE_IPP
00153     private:
00154   
00155       template<typename T, IppStatus (IPP_DECL *ippiFunc) (const T*, int, T*, int, IppiSize, const Ipp8u*, IppiSize, IppiPoint)>
00156       IppStatus ippiMorphologicalCall (const core::Img<T> *src, core::Img<T> *dst);
00157       template<typename T, IppStatus (IPP_DECL *ippiFunc) (const T*, int, T*, int, IppiSize)>
00158       IppStatus ippiMorphologicalCall3x3 (const core::Img<T> *src, core::Img<T> *dst);
00159   
00160       template<typename T, IppStatus (IPP_DECL *ippiFunc) (const T*, int, T*, int, IppiSize, _IppiBorderType, IppiMorphState*)>
00161       IppStatus ippiMorphologicalBorderReplicateCall (const core::Img<T> *src, core::Img<T> *dst,IppiMorphState *state);
00162   
00163       template<typename T, IppStatus (IPP_DECL *ippiFunc) (const T*, int, T*, int, IppiSize, IppiBorderType, IppiMorphAdvState*)>
00164       IppStatus ippiMorphologicalBorderCall (const core::Img<T> *src, core::Img<T> *dst, IppiMorphAdvState *advState);
00165   
00166       typedef IppiMorphState ICLMorphState ;
00167       typedef IppiMorphAdvState ICLMorphAdvState;
00168   #else
00169       typedef void ICLMorphState;
00170       typedef void ICLMorphAdvState;
00171       core::ImgBase *m_openingAndClosingBuffer;
00172       core::ImgBase *m_gradientBorderBuffer_1;
00173       core::ImgBase *m_gradientBorderBuffer_2;
00174   
00175     private:
00176       template<class T>
00177       void apply_t(const core::ImgBase *src, core::ImgBase **dst);
00178   #endif
00179     private:
00180       icl8u * m_pcMask;
00181       utils::Size m_oMaskSizeMorphOp; // actually masksize of NeighborhoodOp and MorphOp may be different
00182       ICLMorphState* m_pState8u;
00183       ICLMorphState* m_pState32f;
00184       ICLMorphAdvState* m_pAdvState8u;
00185       ICLMorphAdvState* m_pAdvState32f;
00186       bool m_bMorphState8u;
00187       bool m_bMorphState32f;
00188       bool m_bMorphAdvState8u;
00189       bool m_bMorphAdvState32f;
00190       bool m_bHas_changed;
00191       bool m_bHas_changedAdv;
00192       void deleteMorphStates();
00193       void checkMorphAdvState8u(const utils::Size roiSize);
00194       void checkMorphAdvState32f(const utils::Size roiSize);
00195       void checkMorphState8u(const utils::Size roiSize);
00196       void checkMorphState32f(const utils::Size roiSize);
00197     
00198       
00199       optype m_eType;
00200   
00201     };
00202   } // namespace filter
00203 } // namespace icl
00204 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines