ConditionalEuclideanClustering performs segmentation based on Euclidean distance and a user-defined clustering condition. More...
#include <conditional_euclidean_clustering.h>
Public Member Functions | |
ConditionalEuclideanClustering (bool extract_removed_clusters=false) | |
Constructor. | |
float | getClusterTolerance () |
Get the spatial tolerance for new cluster candidates. | |
int | getMaxClusterSize () |
Get the maximum number of points that a cluster needs to contain in order to be considered valid. | |
int | getMinClusterSize () |
Get the minimum number of points that a cluster needs to contain in order to be considered valid. | |
void | getRemovedClusters (IndicesClustersPtr &small_clusters, IndicesClustersPtr &large_clusters) |
Get the clusters that are invalidated due to size constraints. | |
void | segment (IndicesClusters &clusters) |
Segment the input into separate clusters. | |
void | setClusterTolerance (float cluster_tolerance) |
Set the spatial tolerance for new cluster candidates. | |
void | setConditionFunction (bool(*condition_function)(const PointT &, const PointT &, float)) |
Set the condition that needs to hold for neighboring points to be considered part of the same cluster. | |
void | setMaxClusterSize (int max_cluster_size) |
Set the maximum number of points that a cluster needs to contain in order to be considered valid. | |
void | setMinClusterSize (int min_cluster_size) |
Set the minimum number of points that a cluster needs to contain in order to be considered valid. | |
Protected Types | |
typedef pcl::search::Search < PointT >::Ptr | SearcherPtr |
Private Attributes | |
float | cluster_tolerance_ |
The distance to scan for cluster candidates (default = 0.0) | |
bool(* | condition_function_ )(const PointT &, const PointT &, float) |
The condition function that needs to hold for clustering. | |
bool | extract_removed_clusters_ |
Set to true if you want to be able to extract the clusters that are too large or too small (default = false) | |
pcl::IndicesClustersPtr | large_clusters_ |
The resultant clusters that contain more than max_cluster_size points. | |
int | max_cluster_size_ |
The maximum cluster size (default = unlimited) | |
int | min_cluster_size_ |
The minimum cluster size (default = 1) | |
SearcherPtr | searcher_ |
A pointer to the spatial search object. | |
pcl::IndicesClustersPtr | small_clusters_ |
The resultant clusters that contain less than min_cluster_size points. |
ConditionalEuclideanClustering performs segmentation based on Euclidean distance and a user-defined clustering condition.
The condition that need to hold is currently passed using a function pointer. For more information check the documentation of setConditionFunction() or the usage example below:
bool enforceIntensitySimilarity (const pcl::PointXYZI& point_a, const pcl::PointXYZI& point_b, float squared_distance) { if (fabs (point_a.intensity - point_b.intensity) < 0.1f) return (true); else return (false); } // ... // Somewhere down to the main code // ... pcl::ConditionalEuclideanClustering<pcl::PointXYZI> cec (true); cec.setInputCloud (cloud_in); cec.setConditionFunction (&enforceIntensitySimilarity); // Points within this distance from one another are going to need to validate the enforceIntensitySimilarity function to be part of the same cluster: cec.setClusterTolerance (0.09f); // Size constraints for the clusters: cec.setMinClusterSize (5); cec.setMaxClusterSize (30); // The resulting clusters (an array of pointindices): cec.segment (*clusters); // The clusters that are too small or too large in size can also be extracted separately: cec.getRemovedClusters (small_clusters, large_clusters);
Definition at line 81 of file conditional_euclidean_clustering.h.
typedef pcl::search::Search<PointT>::Ptr pcl::ConditionalEuclideanClustering< PointT >::SearcherPtr [protected] |
Definition at line 84 of file conditional_euclidean_clustering.h.
pcl::ConditionalEuclideanClustering< PointT >::ConditionalEuclideanClustering | ( | bool | extract_removed_clusters = false | ) | [inline] |
Constructor.
[in] | extract_removed_clusters | Set to true if you want to be able to extract the clusters that are too large or too small (default = false) |
Definition at line 95 of file conditional_euclidean_clustering.h.
float pcl::ConditionalEuclideanClustering< PointT >::getClusterTolerance | ( | ) | [inline] |
Get the spatial tolerance for new cluster candidates.
Definition at line 143 of file conditional_euclidean_clustering.h.
int pcl::ConditionalEuclideanClustering< PointT >::getMaxClusterSize | ( | ) | [inline] |
Get the maximum number of points that a cluster needs to contain in order to be considered valid.
Definition at line 175 of file conditional_euclidean_clustering.h.
int pcl::ConditionalEuclideanClustering< PointT >::getMinClusterSize | ( | ) | [inline] |
Get the minimum number of points that a cluster needs to contain in order to be considered valid.
Definition at line 159 of file conditional_euclidean_clustering.h.
void pcl::ConditionalEuclideanClustering< PointT >::getRemovedClusters | ( | IndicesClustersPtr & | small_clusters, |
IndicesClustersPtr & | large_clusters | ||
) | [inline] |
Get the clusters that are invalidated due to size constraints.
[out] | small_clusters | The resultant clusters that contain less than min_cluster_size points |
[out] | large_clusters | The resultant clusters that contain more than max_cluster_size points |
Definition at line 198 of file conditional_euclidean_clustering.h.
void pcl::ConditionalEuclideanClustering< PointT >::segment | ( | pcl::IndicesClusters & | clusters | ) |
Segment the input into separate clusters.
The input can be set using setInputCloud() and setIndices().
The size constraints for the resulting clusters can be set using setMinClusterSize() and setMaxClusterSize().
The region growing parameters can be set using setConditionFunction() and setClusterTolerance().
[out] | clusters | The resultant set of indices, indexing the points of the input cloud that correspond to the clusters |
Definition at line 43 of file conditional_euclidean_clustering.hpp.
void pcl::ConditionalEuclideanClustering< PointT >::setClusterTolerance | ( | float | cluster_tolerance | ) | [inline] |
Set the spatial tolerance for new cluster candidates.
Any two points within this distance from one another will need to evaluate a certain condition in order to be made part of the same cluster. The condition can be set using setConditionFunction().
[in] | cluster_tolerance | The distance to scan for cluster candidates (default = 0.0) |
Definition at line 136 of file conditional_euclidean_clustering.h.
void pcl::ConditionalEuclideanClustering< PointT >::setConditionFunction | ( | bool(*)(const PointT &, const PointT &, float) | condition_function | ) | [inline] |
Set the condition that needs to hold for neighboring points to be considered part of the same cluster.
Any two points within a certain distance from one another will need to evaluate this condition in order to be made part of the same cluster. The distance can be set using setClusterTolerance().
Note that for a point to be part of a cluster, the condition only needs to hold for at least 1 point pair. To clarify, the following statement is false: Any two points within a cluster always evaluate this condition function to true.
The input arguments of the condition function are:
The output argument is a boolean, returning true will merge the second point into the cluster of the first point.
[in] | condition_function | The condition function that needs to hold for clustering |
Definition at line 125 of file conditional_euclidean_clustering.h.
void pcl::ConditionalEuclideanClustering< PointT >::setMaxClusterSize | ( | int | max_cluster_size | ) | [inline] |
Set the maximum number of points that a cluster needs to contain in order to be considered valid.
[in] | max_cluster_size | The maximum cluster size (default = unlimited) |
Definition at line 168 of file conditional_euclidean_clustering.h.
void pcl::ConditionalEuclideanClustering< PointT >::setMinClusterSize | ( | int | min_cluster_size | ) | [inline] |
Set the minimum number of points that a cluster needs to contain in order to be considered valid.
[in] | min_cluster_size | The minimum cluster size (default = 1) |
Definition at line 152 of file conditional_euclidean_clustering.h.
float pcl::ConditionalEuclideanClustering< PointT >::cluster_tolerance_ [private] |
The distance to scan for cluster candidates (default = 0.0)
Definition at line 217 of file conditional_euclidean_clustering.h.
bool(* pcl::ConditionalEuclideanClustering< PointT >::condition_function_)(const PointT &, const PointT &, float) [private] |
The condition function that needs to hold for clustering.
Definition at line 214 of file conditional_euclidean_clustering.h.
bool pcl::ConditionalEuclideanClustering< PointT >::extract_removed_clusters_ [private] |
Set to true if you want to be able to extract the clusters that are too large or too small (default = false)
Definition at line 226 of file conditional_euclidean_clustering.h.
pcl::IndicesClustersPtr pcl::ConditionalEuclideanClustering< PointT >::large_clusters_ [private] |
The resultant clusters that contain more than max_cluster_size points.
Definition at line 232 of file conditional_euclidean_clustering.h.
int pcl::ConditionalEuclideanClustering< PointT >::max_cluster_size_ [private] |
The maximum cluster size (default = unlimited)
Definition at line 223 of file conditional_euclidean_clustering.h.
int pcl::ConditionalEuclideanClustering< PointT >::min_cluster_size_ [private] |
The minimum cluster size (default = 1)
Definition at line 220 of file conditional_euclidean_clustering.h.
SearcherPtr pcl::ConditionalEuclideanClustering< PointT >::searcher_ [private] |
A pointer to the spatial search object.
Definition at line 211 of file conditional_euclidean_clustering.h.
pcl::IndicesClustersPtr pcl::ConditionalEuclideanClustering< PointT >::small_clusters_ [private] |
The resultant clusters that contain less than min_cluster_size points.
Definition at line 229 of file conditional_euclidean_clustering.h.