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/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.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 #pragma once 00031 00032 #include <ICLUtils/CompatMacros.h> 00033 #include <ICLCore/Img.h> 00034 #include <ICLCore/Color.h> 00035 #include <ICLFilter/UnaryOp.h> 00036 00037 namespace icl{ 00038 namespace filter{ 00040 00112 class ICLFilter_API ColorSegmentationOp : public UnaryOp{ 00113 public: 00115 class LUT3D; 00116 00117 private: 00118 core::format m_segFormat; 00119 core::Img8u m_inputBuffer; 00120 core::Img8u m_outputBuffer; 00121 core::Img8u m_segPreview; 00122 core::Img8u m_lastDst; 00123 icl8u m_bitShifts[3]; 00124 LUT3D *m_lut; 00125 00126 public: 00127 00129 00134 ColorSegmentationOp(icl8u c0shift=2, icl8u c1shift=2, icl8u c2shift=2,core::format fmt=core::formatYUV) throw (utils::ICLException); 00135 00137 ~ColorSegmentationOp(); 00138 00140 virtual void apply(const core::ImgBase *src, core::ImgBase **dst); 00141 00143 using UnaryOp::apply; 00144 00146 icl8u classifyPixel(icl8u r, icl8u g, icl8u b); 00147 00149 void clearLUT(icl8u value=0); 00150 00152 void setSegmentationShifts(icl8u c0shift, icl8u c1shift, icl8u c2shift); 00153 00155 void setSegmentationFormat(core::format fmt) throw (utils::ICLException); 00156 00158 const icl8u *getSegmentationShifts() const { return m_bitShifts; } 00159 00161 core::format getSegmentationFormat() const { return m_segFormat; } 00162 00164 00166 const core::Img8u &getSegmentationPreview(); 00167 00168 00170 void lutEntry(icl8u a, icl8u b, icl8u c, icl8u rA, icl8u rB, icl8u rC, icl8u value); 00171 00173 void lutEntry(core::format fmt, int a, int b, int c, int rA, int rB, int rC, icl8u value) throw (utils::ICLException); 00174 00176 void load(const std::string &filename); 00177 00179 void save(const std::string &filename); 00180 00182 00185 const core::Img8u &getLUTPreview(int xDim, int yDim, icl8u zValue); 00186 00188 00190 const core::Img8u &getColoredLUTPreview(int xDim, int yDim, icl8u zValue); 00191 00193 const std::vector<core::Color> &getClassMeanColors(); 00194 00196 00198 const icl8u *getLUT() const; 00199 00201 00202 icl8u *getLUT(); 00203 00205 00206 void getLUTDims(int &w, int &h, int &t) const; 00207 00208 }; 00209 00210 } // namespace filter 00211 } 00212