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