Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ColorSegmentationOp.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/ColorSegmentationOp.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 #pragma once
00031 
00032 #include <ICLFilter/UnaryOp.h>
00033 #include <ICLCore/Img.h>
00034 #include <ICLCore/Color.h>
00035 
00036 namespace icl{
00037   namespace filter{
00039 
00111     class ColorSegmentationOp : public UnaryOp{
00112       public:
00114       class LUT3D; 
00115   
00116       private:
00117       core::format m_segFormat;       
00118       core::Img8u m_inputBuffer;      
00119       core::Img8u m_outputBuffer;     
00120       core::Img8u m_segPreview;       
00121       core::Img8u m_lastDst;          
00122       icl8u m_bitShifts[3];     
00123       LUT3D *m_lut;             
00124   
00125       public:
00126       
00128 
00133       ColorSegmentationOp(icl8u c0shift=2, icl8u c1shift=2, icl8u c2shift=2,core::format fmt=core::formatYUV) throw (utils::ICLException);
00134   
00136       ~ColorSegmentationOp();
00137       
00139       virtual void apply(const core::ImgBase *src, core::ImgBase **dst);
00140       
00142       using UnaryOp::apply;
00143       
00145       icl8u classifyPixel(icl8u r, icl8u g, icl8u b);
00146           
00148       void clearLUT(icl8u value=0);
00149       
00151       void setSegmentationShifts(icl8u c0shift, icl8u c1shift, icl8u c2shift);
00152       
00154       void setSegmentationFormat(core::format fmt) throw (utils::ICLException);
00155   
00157       const icl8u *getSegmentationShifts() const { return m_bitShifts; }
00158       
00160       core::format getSegmentationFormat() const { return m_segFormat; }
00161       
00163 
00165       const core::Img8u &getSegmentationPreview();
00166       
00167   
00169       void lutEntry(icl8u a, icl8u b, icl8u c, icl8u rA, icl8u rB, icl8u rC, icl8u value);
00170       
00172       void lutEntry(core::format fmt, int a, int b, int c, int rA, int rB, int rC, icl8u value) throw (utils::ICLException);
00173       
00175       void load(const std::string &filename);
00176       
00178       void save(const std::string &filename);
00179       
00181 
00184       const core::Img8u &getLUTPreview(int xDim, int yDim, icl8u zValue);
00185   
00187 
00189       const core::Img8u &getColoredLUTPreview(int xDim, int yDim, icl8u zValue);
00190       
00192       const std::vector<core::Color> &getClassMeanColors();
00193       
00195 
00197       const icl8u *getLUT() const;
00198   
00200 
00201       icl8u *getLUT();
00202   
00204 
00205       void getLUTDims(int &w, int &h, int &t) const;
00206   
00207     };
00208   
00209   } // namespace filter
00210 }
00211 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines