Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
LUTOp3Channel.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/LUTOp3Channel.h                **
00010 ** Module : ICLFilter                                              **
00011 ** Authors: Christof Elbrechter                                    **
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/UnaryOp.h>
00034 #include <ICLCore/Img.h>
00035 #include <vector>
00036 #include <ICLUtils/Uncopyable.h>
00037 
00038 namespace icl {
00039   namespace filter{
00040   
00042 
00152     template<class T>
00153     class LUTOp3Channel : public UnaryOp, public utils::Uncopyable {
00154       public:
00155       
00157 
00161       class Plugin{
00162         public:
00164         Plugin(){}
00166 
00171         Plugin(int ref1, int ref2, int ref3, int thresh){
00172           m_aiRef[0] = ref1;
00173           m_aiRef[1] = ref2;
00174           m_aiRef[2] = ref3;
00175           m_iThresh = thresh;
00176         }
00178         virtual ~Plugin(){}
00179         
00181 
00194         virtual T transform(int v1, int v2, int v3){
00195           return ::sqrt( ::pow((float) (v1-m_aiRef[0]),2) + 
00196                          ::pow((float) (v2-m_aiRef[1]),2) + 
00197                          ::pow((float) (v3-m_aiRef[2]),2) ) / 
00198                          ::sqrt(3.0) < m_iThresh ? T(255) : T(0);
00199         }
00200         private:
00201   
00203         int m_aiRef[3];
00204   
00206         int m_iThresh;
00207       };
00208   
00210 
00215       LUTOp3Channel(Plugin *p=0, icl8u shift=0);
00216       
00218       virtual ~LUTOp3Channel();
00219       
00221 
00224       virtual void apply(const core::ImgBase *src, core::ImgBase **dst);
00225       
00227       using UnaryOp::apply;
00228       
00230 
00234       void setPlugin(Plugin *p);
00235       
00237       Plugin *removePlugin(){
00238         Plugin *p = m_poPlugin;
00239         m_poPlugin = 0;
00240         return p;
00241       }
00242   
00243       private:
00244       
00246       core::Img<T> m_oLUT;
00247       
00249       Plugin *m_poPlugin;
00250       
00252       icl8u m_ucShift;
00253     };
00254   } // namespace filter
00255 } // namespace icl
00256 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines