Image Component Library (ICL)
ColorSegmentationOp.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLFilter/src/ICLFilter/ColorSegmentationOp.h **
10 ** Module : ICLFilter **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 #pragma once
31 
32 #include <ICLUtils/CompatMacros.h>
33 #include <ICLCore/Img.h>
34 #include <ICLCore/Color.h>
35 #include <ICLFilter/UnaryOp.h>
36 
37 namespace icl{
38  namespace filter{
40 
113  public:
115  class LUT3D;
116 
117  private:
123  icl8u m_bitShifts[3];
124  LUT3D *m_lut;
125 
126  public:
127 
129 
134  ColorSegmentationOp(icl8u c0shift=2, icl8u c1shift=2, icl8u c2shift=2,core::format fmt=core::formatYUV) ;
135 
138 
140  virtual void apply(const core::ImgBase *src, core::ImgBase **dst);
141 
143  using UnaryOp::apply;
144 
146  icl8u classifyPixel(icl8u r, icl8u g, icl8u b);
147 
149  void clearLUT(icl8u value=0);
150 
152  void setSegmentationShifts(icl8u c0shift, icl8u c1shift, icl8u c2shift);
153 
155  void setSegmentationFormat(core::format fmt) ;
156 
158  const icl8u *getSegmentationShifts() const { return m_bitShifts; }
159 
161  core::format getSegmentationFormat() const { return m_segFormat; }
162 
164 
166  const core::Img8u &getSegmentationPreview();
167 
168 
170  void lutEntry(icl8u a, icl8u b, icl8u c, icl8u rA, icl8u rB, icl8u rC, icl8u value);
171 
173  void lutEntry(core::format fmt, int a, int b, int c, int rA, int rB, int rC, icl8u value) ;
174 
176  void load(const std::string &filename);
177 
179  void save(const std::string &filename);
180 
182 
185  const core::Img8u &getLUTPreview(int xDim, int yDim, icl8u zValue);
186 
188 
190  const core::Img8u &getColoredLUTPreview(int xDim, int yDim, icl8u zValue);
191 
193  const std::vector<core::Color> &getClassMeanColors();
194 
196 
198  const icl8u *getLUT() const;
199 
201 
202  icl8u *getLUT();
203 
205 
206  void getLUTDims(int &w, int &h, int &t) const;
207 
208  };
209 
210  } // namespace filter
211 }
212 
ICLQt_API void save(const core::ImgBase &image, const std::string &filename)
write an image to HD
undocument this line if you encounter any issues!
Definition: Any.h:37
Ipp8u icl8u
8Bit unsigned integer type for the ICL
Definition: BasicTypes.h:64
core::Img8u m_segPreview
internal buffer for providing a preview of the current segmentation
Definition: ColorSegmentationOp.h:121
const icl8u * getSegmentationShifts() const
returns the pointer to the 3 internally used segmentation shifts
Definition: ColorSegmentationOp.h:158
ICLQt_API core::Img< T > load(const std::string &filename)
load an image file read file (affinity for floats)
Definition: Types.h:74
Class for fast LUT-based color segmentation.
Definition: ColorSegmentationOp.h:112
core::Img8u m_outputBuffer
internal buffer holding the output image
Definition: ColorSegmentationOp.h:120
core::Img8u m_lastDst
last used destination image
Definition: ColorSegmentationOp.h:122
core::format m_segFormat
format, that is used for internal segmentation
Definition: ColorSegmentationOp.h:115
core::format getSegmentationFormat() const
returns the current internally used segmentation format
Definition: ColorSegmentationOp.h:161
format
determines the color-format, that is associated with the images channels
Definition: Types.h:70
core::Img8u m_inputBuffer
internal image in depth8u and segmentation format
Definition: ColorSegmentationOp.h:119
Abstract Base class for Unary Operators.
Definition: UnaryOp.h:51
LUT3D * m_lut
color classification lookup table
Definition: ColorSegmentationOp.h:124
ICLQt_API core::Img< T > filter(const core::Img< T > &image, const std::string &filter)
applies a filter operation on the source image (affinity for float)
#define ICLFilter_API
Definition: CompatMacros.h:175
virtual void apply(const core::ImgBase *operand1, core::ImgBase **dst)=0
pure virtual apply function, that must be implemented in all derived classes
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131