Image Component Library (ICL)
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
icl::geom::SegmenterUtils Class Reference

Support class for segmentation algorithms. More...

#include <SegmenterUtils.h>

Public Types

enum  Mode { BEST, GPU, CPU }
 

Public Member Functions

 SegmenterUtils (Mode mode=BEST)
 Constructor. More...
 
 ~SegmenterUtils ()
 Destructor. More...
 
core::Img8u createColorImage (core::Img32s &labelImage)
 Creates a color image (e.g. for pointcloud coloring) from a given segmentation label image. More...
 
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). More...
 
core::Img8u createMask (core::Img32f &depthImage)
 Creates the mask image for segmentation. More...
 
core::Img32s stabelizeSegmentation (core::Img32s &labelImage)
 Minimizes the label ID changes from frame to frame. The overlaps between the current and the previous label image are calculated and relabeled for the result. More...
 
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(...) if edge point assignment is needed as well. More...
 
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(...) if adjacency matrix is needed as well. More...
 
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. More...
 
std::vector< std::vector< int > > extractSegments (core::Img32s &labelImage)
 Extracts the segments from a label image. More...
 
void relabel (core::Img32s &labelImage, std::vector< std::vector< int > > &assignment, int maxOldLabel=0)
 Relabels the label image. More...
 

Static Public Member Functions

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 line). More...
 
static std::vector< std::vector< int > > createLabelVectors (core::Img32s &labelImage)
 Creates the label vectors from a given label image. More...
 

Private Member Functions

void createColorImageCL (core::Img32s &labelImage, core::Img8u &colorImage)
 
void createColorImageCPU (core::Img32s &labelImage, core::Img8u &colorImage)
 
std::vector< int > calculateLabelReassignment (int countCur, int countLast, core::Channel32s &labelImageC, core::Channel32s &lastLabelImageC, utils::Size size)
 
math::DynMatrix< bool > edgePointAssignmentAndAdjacencyMatrixCL (core::DataSegment< float, 4 > &xyzh, core::Img32s &labelImage, core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces, bool pointAssignment)
 
math::DynMatrix< bool > edgePointAssignmentAndAdjacencyMatrixCPU (core::DataSegment< float, 4 > &xyzh, core::Img32s &labelImage, core::Img8u &maskImage, int radius, float euclideanDistance, int numSurfaces, bool pointAssignment)
 

Static Private Member Functions

static float dist3 (const Vec &a, const Vec &b)
 

Private Attributes

Data * m_data
 internal data type More...
 

Detailed Description

Support class for segmentation algorithms.

This class provides supporting methods for segmentation algorithms.

Member Enumeration Documentation

◆ Mode

Enumerator
BEST 
GPU 
CPU 

Constructor & Destructor Documentation

◆ SegmenterUtils()

icl::geom::SegmenterUtils::SegmenterUtils ( Mode  mode = BEST)

Constructor.

Constructs an object of this class.

Parameters
modethe selected mode: CPU, GPU or BEST (uses GPU if available)

◆ ~SegmenterUtils()

icl::geom::SegmenterUtils::~SegmenterUtils ( )

Destructor.

Member Function Documentation

◆ calculateAdjacencyMatrix()

math::DynMatrix<bool> icl::geom::SegmenterUtils::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(...) if edge point assignment is needed as well.

Parameters
xyzhthe input pointcloud (point position)
labelImagethe input label image
maskImagethe input mask image
radiusin pixel (distance of surfaces/segments around separating edge)
euclideanDistancethe maximum euclidean distance between adjacent surfaces/segments
numSurfacesthe number of surfaces/segments in the label image
Returns
the adjacency matrix.

◆ calculateLabelReassignment()

std::vector<int> icl::geom::SegmenterUtils::calculateLabelReassignment ( int  countCur,
int  countLast,
core::Channel32s &  labelImageC,
core::Channel32s &  lastLabelImageC,
utils::Size  size 
)
private

◆ createColorImage()

core::Img8u icl::geom::SegmenterUtils::createColorImage ( core::Img32s labelImage)

Creates a color image (e.g. for pointcloud coloring) from a given segmentation label image.

Parameters
labelImagethe input label image
Returns
the output color image.

◆ createColorImageCL()

void icl::geom::SegmenterUtils::createColorImageCL ( core::Img32s labelImage,
core::Img8u colorImage 
)
private

◆ createColorImageCPU()

void icl::geom::SegmenterUtils::createColorImageCPU ( core::Img32s labelImage,
core::Img8u colorImage 
)
private

◆ createLabelVectors()

static std::vector<std::vector<int> > icl::geom::SegmenterUtils::createLabelVectors ( core::Img32s labelImage)
static

Creates the label vectors from a given label image.

Parameters
labelImagethe input label image
Returns
the vector of id vectors

◆ createMask()

core::Img8u icl::geom::SegmenterUtils::createMask ( core::Img32f depthImage)

Creates the mask image for segmentation.

Parameters
depthImagethe input depth image
Returns
the output mask image.

◆ createROIMask()

core::Img8u icl::geom::SegmenterUtils::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).

Parameters
xyzhthe input pointcloud (point position)
depthImagethe input depth image @xMin parameter for ROI (in mm for world coordinates) @xMax parameter for ROI (in mm for world coordinates) @yMin parameter for ROI (in mm for world coordinates) @yMax parameter for ROI (in mm for world coordinates) @zMin parameter for ROI (in mm for world coordinates) @zMax parameter for ROI (in mm for world coordinates)
Returns
the output mask image.

◆ dist3()

static float icl::geom::SegmenterUtils::dist3 ( const Vec a,
const Vec b 
)
inlinestaticprivate

◆ edgePointAssignment()

void icl::geom::SegmenterUtils::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(...) if adjacency matrix is needed as well.

Parameters
xyzhthe input pointcloud (point position)
labelImagethe input label image (changed by the method)
maskImagethe input mask image (changed by the method)
radiusin pixel (distance of surfaces/segments around separating edge)
euclideanDistancethe maximum euclidean distance between adjacent surfaces/segments
numSurfacesthe number of surfaces/segments in the label image

◆ edgePointAssignmentAndAdjacencyMatrix()

math::DynMatrix<bool> icl::geom::SegmenterUtils::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.

Parameters
xyzhthe input pointcloud (point position)
labelImagethe input label image (changed by the method)
maskImagethe input mask image (changed by the method)
radiusin pixel (distance of surfaces/segments around separating edge)
euclideanDistancethe maximum euclidean distance between adjacent surfaces/segments
numSurfacesthe number of surfaces/segments in the label image
Returns
the adjacency matrix.

◆ edgePointAssignmentAndAdjacencyMatrixCL()

math::DynMatrix<bool> icl::geom::SegmenterUtils::edgePointAssignmentAndAdjacencyMatrixCL ( core::DataSegment< float, 4 > &  xyzh,
core::Img32s labelImage,
core::Img8u maskImage,
int  radius,
float  euclideanDistance,
int  numSurfaces,
bool  pointAssignment 
)
private

◆ edgePointAssignmentAndAdjacencyMatrixCPU()

math::DynMatrix<bool> icl::geom::SegmenterUtils::edgePointAssignmentAndAdjacencyMatrixCPU ( core::DataSegment< float, 4 > &  xyzh,
core::Img32s labelImage,
core::Img8u maskImage,
int  radius,
float  euclideanDistance,
int  numSurfaces,
bool  pointAssignment 
)
private

◆ extractSegments()

std::vector<std::vector<int> > icl::geom::SegmenterUtils::extractSegments ( core::Img32s labelImage)

Extracts the segments from a label image.

Parameters
labelImagethe input label image
Returns
a vector of pointID vectors.

◆ occlusionCheck()

static bool icl::geom::SegmenterUtils::occlusionCheck ( core::Img32f depthImage,
utils::Point  p1,
utils::Point  p2,
float  distanceTolerance = 3.,
float  outlierTolerance = 5. 
)
static

Checks if there is occlusion between two points (depth of all points on or in front of an augmented line).

Parameters
depthImagethe input depth image
p1the first image point
p2the second image point
distanceTolerancethe distance tolerance in depthUnits
outlierTolerancemaximum number of outlier points in percent
Returns
true if occluded.

◆ relabel()

void icl::geom::SegmenterUtils::relabel ( core::Img32s labelImage,
std::vector< std::vector< int > > &  assignment,
int  maxOldLabel = 0 
)

Relabels the label image.

Parameters
labelImagethe input/output label image
assignmenta vector of vectors with label ids. Each label from the inner id is replaced by the outer vector id.
maxOldLabelthe maximum id of the old labels (optional)

◆ stabelizeSegmentation()

core::Img32s icl::geom::SegmenterUtils::stabelizeSegmentation ( core::Img32s labelImage)

Minimizes the label ID changes from frame to frame. The overlaps between the current and the previous label image are calculated and relabeled for the result.

Parameters
labelImagethe input label image
Returns
the stabelized output label image.

Member Data Documentation

◆ m_data

Data* icl::geom::SegmenterUtils::m_data
private

internal data type

internal data pointer


The documentation for this class was generated from the following file: