Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MotionSensitiveTemporalSmoothing.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/MotionSensitiveTemporalSmoothi **
00010 **          ng.h                                                   **
00011 ** Module : ICLFilter                                              **
00012 ** Authors: Andre Ueckermann                                       **
00013 **                                                                 **
00014 **                                                                 **
00015 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00016 ** This file may be used under the terms of the GNU Lesser General **
00017 ** Public License version 3.0 as published by the                  **
00018 **                                                                 **
00019 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
00020 ** included in the packaging of this file.  Please review the      **
00021 ** following information to ensure the license requirements will   **
00022 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00023 **                                                                 **
00024 ** The development of this software was supported by the           **
00025 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00026 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00027 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00028 ** Excellence Initiative.                                          **
00029 **                                                                 **
00030 ********************************************************************/
00031 
00032 #pragma once
00033 
00034 #include <ICLUtils/CompatMacros.h>
00035 #include <ICLUtils/Uncopyable.h>
00036 #include <ICLCore/Img.h>
00037 #include <ICLFilter/UnaryOp.h>
00038 
00039 #ifdef ICL_HAVE_OPENCL    
00040 #include <ICLUtils/CLProgram.h>
00041 #include <ICLUtils/CLKernel.h>
00042 #include <ICLUtils/CLBuffer.h>
00043 #endif
00044 
00045 namespace icl{
00046   namespace filter{
00047   
00048     class ICLFilter_API TemporalSmoothingCL{
00049       public:
00050       
00052 
00055       TemporalSmoothingCL(utils::Size size, core::depth depth, int iMaxFilterSize, int iNullValue);
00056   
00058       ~TemporalSmoothingCL();
00059       
00061 
00063       core::Img32f temporalSmoothingF(const core::Img32f &inputImage);
00064       
00066 
00068       core::Img8u temporalSmoothingC(const core::Img8u &inputImage);
00069       
00071 
00072             void setUseCL(bool use);
00073             
00075 
00076             void setFilterSize(int iFilterSize);
00077             
00079 
00080             void setDifference(int iDifference);
00081             
00083 
00084             core::Img32f getMotionImage();
00085             
00087 
00088             bool isCLReady();
00089             
00091 
00092             bool isCLActive();
00093                   
00094      private:
00095      
00096       int w,h;
00097       core::depth d;
00098       bool clReady;
00099       bool useCL;
00100       
00101       int imgCount;
00102       
00103       int filterSize;
00104       int currentFilterSize;
00105       int maxFilterSize;
00106       
00107       int currentDifference;
00108       int nullValue;
00109         
00110       std::vector<core::Img32f> inputImagesF;
00111       core::Img32f outputImageF;         
00112       std::vector<core::Img8u> inputImagesC;
00113       core::Img8u outputImageC; 
00114       core::Img32f motionImage;     
00115         
00116     #ifdef ICL_HAVE_OPENCL
00117       //OpenCL    
00118       float* inputImage1ArrayF;
00119       float* inputImagesArrayF;
00120       float* outputImageArrayF;
00121       
00122       unsigned char* inputImage1ArrayC;
00123       unsigned char* inputImagesArrayC;
00124       unsigned char* outputImageArrayC;
00125       
00126       float* motionImageArray;
00127       
00128 
00129       //OpenCL
00130       utils::CLProgram program;
00131       utils::CLKernel kernelTemporalSmoothingFloat;
00132       utils::CLKernel kernelTemporalSmoothingChar;
00133       utils::CLKernel kernelCheckRANSAC;
00134       utils::CLKernel kernelAssignRANSAC;
00135 
00136       //OpenCL buffer
00137       utils::CLBuffer inputImageBufferF;
00138       utils::CLBuffer outputImageBufferF;
00139       utils::CLBuffer inputImageBufferC;
00140       utils::CLBuffer outputImageBufferC;
00141       utils::CLBuffer motionImageBuffer;
00142     #endif
00143   
00144     };
00145   
00146     class ICLFilter_API MotionSensitiveTemporalSmoothing : public UnaryOp, public utils::Uncopyable{
00147       public:
00148       
00150 
00152       MotionSensitiveTemporalSmoothing(int iNullValue, int iMaxFilterSize);
00153   
00155       ~MotionSensitiveTemporalSmoothing();
00156       
00158 
00162       virtual void apply(const core::ImgBase *src, core::ImgBase **dst);
00163           
00165       using UnaryOp::apply;
00166   
00168 
00169             void setUseCL(bool use);
00170             
00172 
00173             void setFilterSize(int filterSize);
00174             
00176 
00177             void setDifference(int difference);
00178             
00180 
00181             core::Img32f getMotionImage();
00182              
00184 
00185             bool isCLActive();
00186                   
00187      private:
00188      
00189       void init(int iChannels, core::depth iDepth, utils::Size iSize);
00190             
00191       bool useCL;
00192       
00193       int currentFilterSize;
00194       int currentDifference;
00195       
00196       int nullValue;
00197       int maxFilterSize;
00198        
00199       int numChannels;
00200       utils::Size size;
00201       core::depth depth;
00202  
00203       std::vector<TemporalSmoothingCL*> clPointer;     
00204     };
00205     
00206   } // namespace filter
00207 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines