Class RegionGrowing3D
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
Region Growing algorithm in 3D point cloud.
public class RegionGrowing3D : Algorithm, IDisposable
- Inheritance
-
RegionGrowing3D
- Implements
- Inherited Members
Remarks
The key idea of region growing is to merge the nearest neighbor points that satisfy a certain angle threshold into the same region according to the normal between the two points, so as to achieve the purpose of segmentation.
Properties
CurvatureThreshold
Threshold value of curvature. Default is 0.05. Only points with curvature less than the threshold will be considered to belong to the same region. If the curvature of each point is not set, this option will not work.
public virtual double CurvatureThreshold { get; set; }
Property Value
MaxNumberOfNeighbors
The maximum number of neighbors to use including itself. Setting to a non-positive number or default will use the information from nnIdx.
public virtual int MaxNumberOfNeighbors { get; set; }
Property Value
MaxSize
The maximum size of region. Setting to a non-positive number or default will be unlimited.
public virtual int MaxSize { get; set; }
Property Value
MinSize
The minimum size of region. Setting to a non-positive number or default will be unlimited.
public virtual int MinSize { get; set; }
Property Value
NeedSort
Whether the results need to be sorted in descending order by the number of points.
public virtual bool NeedSort { get; set; }
Property Value
NumberOfRegions
The maximum number of regions you want. Setting to a non-positive number or default will be unlimited.
public virtual int NumberOfRegions { get; set; }
Property Value
SmoothModeFlag
Whether to use the smoothness mode. Default is true. If true it will check the angle between the normal of the current point and the normal of its neighbor. Otherwise, it will check the angle between the normal of the seed point and the normal of the current neighbor.
public virtual bool SmoothModeFlag { get; set; }
Property Value
SmoothnessThreshold
Threshold value of the angle between normals, in radian. Default is 30(degree)*PI/180.
public virtual double SmoothnessThreshold { get; set; }
Property Value
Methods
Create()
Creates a RegionGrowing3D object.
public static RegionGrowing3D Create()
Returns
- RegionGrowing3D
RegionGrowing3D instance
GetCurvatures(OutputArray)
Gets the curvature of each point, if set.
public virtual void GetCurvatures(OutputArray curvatures)
Parameters
curvaturesOutputArray
GetSeeds(OutputArray)
Gets the seed points.
public virtual void GetSeeds(OutputArray seeds)
Parameters
seedsOutputArray
Segment(out int[][], OutputArray, InputArray, InputArray, InputArray)
Executes segmentation using the Region Growing algorithm.
public virtual int Segment(out int[][] regionsIdx, OutputArray labels, InputArray inputPts, InputArray normals, InputArray nnIdx)
Parameters
regionsIdxint[][]Index information of all points in each region.
labelsOutputArrayThe label corresponds to the model number, 0 means it does not belong to any model, range [0, Number of final resultant models obtained].
inputPtsInputArrayOriginal point cloud, support vector<Point3f> and Mat of size Nx3/3xN.
normalsInputArrayNormal of each point, support vector<Point3f> and Mat of size Nx3.
nnIdxInputArrayIndex information of nearest neighbors of all points. The first nearest neighbor of each point is itself. Support Mat of size NxK. If the information in a row is [0, 2, 1, -5, -1, 4, 7 ... negative number] it will use only non-negative indexes until it meets a negative number or bound of this row i.e. [0, 2, 1].
Returns
- int
Number of final resultant regions obtained by segmentation.
SetCurvatures(InputArray)
Sets the curvature of each point. If not available, pass an empty array.
public virtual void SetCurvatures(InputArray curvatures)
Parameters
curvaturesInputArray
SetSeeds(InputArray)
Sets the seed points, it will grow according to the seeds. If not set (or set to an empty array), the default method will be used:
- If the curvature of each point is set, the seeds will be sorted in ascending order of curvatures.
- Otherwise, the natural order of the point cloud will be used.
public virtual void SetSeeds(InputArray seeds)
Parameters
seedsInputArray