Image Component Library (ICL)
SegmenterUtils.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 : ICLGeom/src/ICLGeom/SegmenterUtils.h **
10 ** Module : ICLGeom **
11 ** Authors: Andre Ueckermann **
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 
31 #pragma once
32 
33 #include <ICLGeom/GeomDefs.h>
34 #include <ICLCore/DataSegment.h>
35 #include <ICLCore/Channel.h>
36 
37 namespace icl{
38  namespace geom{
39 
41 
44 
45  public:
46  enum Mode {BEST, GPU, CPU};
47 
49 
51  SegmenterUtils(Mode mode=BEST);
52 
53 
56 
57 
59 
63 
65 
76  float xMin, float xMax, float yMin, float yMax, float zMin=-10000, float zMax=10000);
77 
79 
82  core::Img8u createMask(core::Img32f &depthImage);
83 
85 
89 
91 
100  core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces);
101 
103 
111  core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces);
112 
114 
123  core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces);
124 
126 
129  std::vector<std::vector<int> > extractSegments(core::Img32s &labelImage);
130 
132 
136  void relabel(core::Img32s &labelImage, std::vector<std::vector<int> > &assignment, int maxOldLabel=0);
137 
139 
146  static bool occlusionCheck(core::Img32f &depthImage, utils::Point p1, utils::Point p2, float distanceTolerance=3., float outlierTolerance=5.);
147 
149 
152  static std::vector<std::vector<int> > createLabelVectors(core::Img32s &labelImage);
153 
154  private:
155 
156  struct Data;
157  Data *m_data;
158 
160 
162 
163  std::vector<int> calculateLabelReassignment(int countCur, int countLast, core::Channel32s &labelImageC, core::Channel32s &lastLabelImageC, utils::Size size);
164 
166  core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces, bool pointAssignment);
167 
169  core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces, bool pointAssignment);
170 
171  static float dist3(const Vec &a, const Vec &b){
172  return norm3(a-b);
173  }
174 
175  };
176 
177  } // namespace geom
178 }
std::vector< std::vector< int > > extractSegments(core::Img32s &labelImage)
Extracts the segments from a label image.
ICLIO_API void labelImage(core::ImgBase *image, const std::string &label)
draws a label into the upper left image corner
~SegmenterUtils()
Destructor.
core::Img32s stabelizeSegmentation(core::Img32s &labelImage)
Minimizes the label ID changes from frame to frame. The overlaps between the current and the previous...
math::DynMatrix< bool > edgePointAssignmentAndAdjacencyMatrixCPU(core::DataSegment< float, 4 > &xyzh, core::Img32s &labelImage, core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces, bool pointAssignment)
undocument this line if you encounter any issues!
Definition: Any.h:37
math::DynMatrix< bool > edgePointAssignmentAndAdjacencyMatrixCL(core::DataSegment< float, 4 > &xyzh, core::Img32s &labelImage, core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces, bool pointAssignment)
void createColorImageCL(core::Img32s &labelImage, core::Img8u &colorImage)
SegmenterUtils(Mode mode=BEST)
Constructor.
float norm3(const Vec4 &a)
3D- euclidian norm for 4D homogeneous vectors (ignoring the homegeneous component)
Definition: HomogeneousMath.h:174
Mode
Definition: SegmenterUtils.h:46
math::DynMatrix< bool > edgePointAssignmentAndAdjacencyMatrix(core::DataSegment< float, 4 > &xyzh, core::Img32s &labelImage, core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces)
Calculates the adjacency between segments and assigns the edge points to the surfaces.
core::Img8u createColorImage(core::Img32s &labelImage)
Creates a color image (e.g. for pointcloud coloring) from a given segmentation label image.
static bool occlusionCheck(core::Img32f &depthImage, utils::Point p1, utils::Point p2, float distanceTolerance=3., float outlierTolerance=5.)
Checks if there is occlusion between two points (depth of all points on or in front of an augmented l...
Size class of the ICL.
Definition: Size.h:61
core::Img8u createROIMask(core::DataSegment< float, 4 > &xyzh, core::Img32f &depthImage, float xMin, float xMax, float yMin, float yMax, float zMin=-10000, float zMax=10000)
Creates the mask image for segmentation (including 3D ROI).
static std::vector< std::vector< int > > createLabelVectors(core::Img32s &labelImage)
Creates the label vectors from a given label image.
core::Img8u createMask(core::Img32f &depthImage)
Creates the mask image for segmentation.
static float dist3(const Vec &a, const Vec &b)
Definition: SegmenterUtils.h:171
math::DynMatrix< bool > calculateAdjacencyMatrix(core::DataSegment< float, 4 > &xyzh, core::Img32s &labelImage, core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces)
Calculates the adjacency between segments. Use edgePointAssignmentAndAdjacencyMatrix(....
void createColorImageCPU(core::Img32s &labelImage, core::Img8u &colorImage)
void relabel(core::Img32s &labelImage, std::vector< std::vector< int > > &assignment, int maxOldLabel=0)
Relabels the label image.
Definition: SegmenterUtils.h:46
Definition: SegmenterUtils.h:46
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
void edgePointAssignment(core::DataSegment< float, 4 > &xyzh, core::Img32s &labelImage, core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces)
Assigns the edge points to the surfaces. Use edgePointAssignmentAndAdjacencyMatrix(....
Support class for segmentation algorithms.
Definition: SegmenterUtils.h:43
Definition: SegmenterUtils.h:46
std::vector< int > calculateLabelReassignment(int countCur, int countLast, core::Channel32s &labelImageC, core::Channel32s &lastLabelImageC, utils::Size size)
Data * m_data
internal data type
Definition: SegmenterUtils.h:156