Image Component Library (ICL)
|
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.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/UnaryOp.h> 00037 #include <vector> 00038 00039 namespace icl { 00040 namespace filter{ 00041 00043 00153 template<class T> 00154 class ICLFilter_API LUTOp3Channel : public UnaryOp, public utils::Uncopyable { 00155 public: 00156 00158 00162 class ICLFilter_API Plugin{ 00163 public: 00165 Plugin(){} 00167 00172 Plugin(int ref1, int ref2, int ref3, int thresh){ 00173 m_aiRef[0] = ref1; 00174 m_aiRef[1] = ref2; 00175 m_aiRef[2] = ref3; 00176 m_iThresh = thresh; 00177 } 00179 virtual ~Plugin(){} 00180 00182 00195 virtual T transform(int v1, int v2, int v3){ 00196 return ::sqrt( ::pow((float) (v1-m_aiRef[0]),2) + 00197 ::pow((float) (v2-m_aiRef[1]),2) + 00198 ::pow((float) (v3-m_aiRef[2]),2) ) / 00199 ::sqrt(3.0) < m_iThresh ? T(255) : T(0); 00200 } 00201 private: 00202 00204 int m_aiRef[3]; 00205 00207 int m_iThresh; 00208 }; 00209 00211 00216 LUTOp3Channel(Plugin *p=0, icl8u shift=0); 00217 00219 virtual ~LUTOp3Channel(); 00220 00222 00225 virtual void apply(const core::ImgBase *src, core::ImgBase **dst); 00226 00228 using UnaryOp::apply; 00229 00231 00235 void setPlugin(Plugin *p); 00236 00238 Plugin *removePlugin(){ 00239 Plugin *p = m_poPlugin; 00240 m_poPlugin = 0; 00241 return p; 00242 } 00243 00244 private: 00245 00247 core::Img<T> m_oLUT; 00248 00250 Plugin *m_poPlugin; 00251 00253 icl8u m_ucShift; 00254 }; 00255 00256 } // namespace filter 00257 } // namespace icl 00258