Point Cloud Library (PCL)
1.7.0
|
Implementation of the GrabCut segmentation in "GrabCut — Interactive Foreground Extraction using Iterated Graph Cuts" by Carsten Rother, Vladimir Kolmogorov and Andrew Blake. More...
#include <pcl/segmentation/grabcut.h>
Classes | |
struct | NLinks |
Public Types | |
typedef pcl::search::Search < PointT > | KdTree |
typedef pcl::search::Search < PointT >::Ptr | KdTreePtr |
typedef PCLBase< PointT > ::PointCloudConstPtr | PointCloudConstPtr |
typedef PCLBase< PointT > ::PointCloudPtr | PointCloudPtr |
![]() | |
typedef pcl::PointCloud< PointT > | PointCloud |
typedef PointCloud::Ptr | PointCloudPtr |
typedef PointCloud::ConstPtr | PointCloudConstPtr |
typedef boost::shared_ptr < PointIndices > | PointIndicesPtr |
typedef boost::shared_ptr < PointIndices const > | PointIndicesConstPtr |
Public Member Functions | |
GrabCut (uint32_t K=5, float lambda=50.f) | |
Constructor. More... | |
virtual | ~GrabCut () |
Desctructor. More... | |
void | setInputCloud (const PointCloudConstPtr &cloud) |
Provide a pointer to the input dataset. More... | |
void | setBackgroundPoints (const PointCloudConstPtr &background_points) |
Set background points, foreground points = points \ background points. More... | |
void | setBackgroundPointsIndices (int x1, int y1, int x2, int y2) |
Set background indices, foreground indices = indices \ background indices. More... | |
void | setBackgroundPointsIndices (const PointIndicesConstPtr &indices) |
Set background indices, foreground indices = indices \ background indices. More... | |
virtual void | refine () |
Run Grabcut refinement on the hard segmentation. More... | |
virtual int | refineOnce () |
float | getLambda () |
void | setLambda (float lambda) |
Set lambda parameter to user given value. More... | |
uint32_t | getK () |
void | setK (uint32_t K) |
Set K parameter to user given value. More... | |
void | setSearchMethod (const KdTreePtr &tree) |
Provide a pointer to the search object. More... | |
KdTreePtr | getSearchMethod () |
Get a pointer to the search method used. More... | |
void | setNumberOfNeighbours (int nb_neighbours) |
Allows to set the number of neighbours to find. More... | |
int | getNumberOfNeighbours () const |
Returns the number of neighbours to find. More... | |
void | extract (std::vector< pcl::PointIndices > &clusters) |
This method launches the segmentation algorithm and returns the clusters that were obtained during the segmentation. More... | |
![]() | |
PCLBase () | |
Empty constructor. More... | |
PCLBase (const PCLBase &base) | |
Copy constructor. More... | |
virtual | ~PCLBase () |
Destructor. More... | |
PointCloudConstPtr const | getInputCloud () |
Get a pointer to the input point cloud dataset. More... | |
virtual void | setIndices (const IndicesPtr &indices) |
Provide a pointer to the vector of indices that represents the input data. More... | |
virtual void | setIndices (const IndicesConstPtr &indices) |
Provide a pointer to the vector of indices that represents the input data. More... | |
virtual void | setIndices (const PointIndicesConstPtr &indices) |
Provide a pointer to the vector of indices that represents the input data. More... | |
virtual void | setIndices (size_t row_start, size_t col_start, size_t nb_rows, size_t nb_cols) |
Set the indices for the points laying within an interest region of the point cloud. More... | |
IndicesPtr const | getIndices () |
Get a pointer to the vector of indices used. More... | |
const PointT & | operator[] (size_t pos) |
Override PointCloud operator[] to shorten code. More... | |
Protected Types | |
typedef pcl::segmentation::grabcut::BoykovKolmogorov::vertex_descriptor | vertex_descriptor |
Protected Member Functions | |
bool | initCompute () |
void | computeBeta () |
Update hard segmentation after running GraphCut,. More... | |
void | computeL () |
Compute L parameter from given lambda. More... | |
void | computeNLinks () |
Compute NLinks. More... | |
float | computeNLink (uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2) |
Compute NLinks at a specific rectangular location. More... | |
void | setTrimap (const PointIndicesConstPtr &indices, segmentation::grabcut::TrimapValue t) |
Edit Trimap. More... | |
int | updateHardSegmentation () |
virtual void | fitGMMs () |
Fit Gaussian Multi Models. More... | |
void | initGraph () |
Build the graph for GraphCut. More... | |
void | addEdge (vertex_descriptor v1, vertex_descriptor v2, float capacity, float rev_capacity) |
Add an edge to the graph, graph must be oriented so we add the edge and its reverse. More... | |
void | setTerminalWeights (vertex_descriptor v, float source_capacity, float sink_capacity) |
Set the weights of SOURCE –> v and v –> SINK. More... | |
bool | isSource (vertex_descriptor v) |
![]() | |
bool | initCompute () |
This method should get called before starting the actual computation. More... | |
bool | deinitCompute () |
This method should get called after finishing the actual computation. More... | |
Protected Attributes | |
uint32_t | width_ |
image width More... | |
uint32_t | height_ |
image height More... | |
uint32_t | K_ |
Number of GMM components. More... | |
float | lambda_ |
lambda = 50. This value was suggested the GrabCut paper. More... | |
float | beta_ |
beta = 1/2 * average of the squared color distances between all pairs of 8-neighboring pixels. More... | |
float | L_ |
L = a large value to force a pixel to be foreground or background. More... | |
KdTreePtr | tree_ |
Pointer to the spatial search object. More... | |
int | nb_neighbours_ |
Number of neighbours. More... | |
bool | initialized_ |
is segmentation initialized More... | |
std::vector< NLinks > | n_links_ |
Precomputed N-link weights. More... | |
segmentation::grabcut::Image::Ptr | image_ |
Converted input. More... | |
std::vector < segmentation::grabcut::TrimapValue > | trimap_ |
std::vector< std::size_t > | GMM_component_ |
std::vector < segmentation::grabcut::SegmentationValue > | hard_segmentation_ |
std::vector< float > | soft_segmentation_ |
segmentation::grabcut::GMM | background_GMM_ |
segmentation::grabcut::GMM | foreground_GMM_ |
pcl::segmentation::grabcut::BoykovKolmogorov | graph_ |
Graph for Graphcut. More... | |
std::vector< vertex_descriptor > | graph_nodes_ |
Graph nodes. More... | |
![]() | |
PointCloudConstPtr | input_ |
The input point cloud dataset. More... | |
IndicesPtr | indices_ |
A pointer to the vector of point indices to use. More... | |
bool | use_indices_ |
Set to true if point indices are used. More... | |
bool | fake_indices_ |
If no set of indices are given, we construct a set of fake indices that mimic the input PointCloud. More... | |
Implementation of the GrabCut segmentation in "GrabCut — Interactive Foreground Extraction using Iterated Graph Cuts" by Carsten Rother, Vladimir Kolmogorov and Andrew Blake.
typedef pcl::search::Search<PointT> pcl::GrabCut< PointT >::KdTree |
typedef pcl::search::Search<PointT>::Ptr pcl::GrabCut< PointT >::KdTreePtr |
typedef PCLBase<PointT>::PointCloudConstPtr pcl::GrabCut< PointT >::PointCloudConstPtr |
typedef PCLBase<PointT>::PointCloudPtr pcl::GrabCut< PointT >::PointCloudPtr |
|
protected |
|
inline |
|
inlinevirtual |
|
protected |
Add an edge to the graph, graph must be oriented so we add the edge and its reverse.
Definition at line 89 of file grabcut.hpp.
|
protected |
Update hard segmentation after running GraphCut,.
Definition at line 321 of file grabcut.hpp.
References pcl::GrabCut< PointT >::NLinks::dists, pcl::GrabCut< PointT >::NLinks::indices, pcl::isFinite(), pcl::GrabCut< PointT >::NLinks::nb_links, pcl::squaredEuclideanDistance(), and pcl::GrabCut< PointT >::NLinks::weights.
|
protected |
Compute L parameter from given lambda.
Definition at line 362 of file grabcut.hpp.
|
protected |
Compute NLinks at a specific rectangular location.
|
protected |
Compute NLinks.
Definition at line 294 of file grabcut.hpp.
References pcl::GrabCut< PointT >::NLinks::dists, pcl::GrabCut< PointT >::NLinks::indices, pcl::GrabCut< PointT >::NLinks::nb_links, and pcl::GrabCut< PointT >::NLinks::weights.
void pcl::GrabCut< PointT >::extract | ( | std::vector< pcl::PointIndices > & | clusters | ) |
This method launches the segmentation algorithm and returns the clusters that were obtained during the segmentation.
The indices of points belonging to the object will be stored in the cluster with index 1, other indices will be stored in the cluster with index 0.
[out] | clusters | clusters that were obtained. Each cluster is an array of point indices. |
Definition at line 368 of file grabcut.hpp.
References pcl::segmentation::grabcut::SegmentationForeground.
|
protectedvirtual |
Fit Gaussian Multi Models.
Definition at line 143 of file grabcut.hpp.
References pcl::segmentation::grabcut::buildGMMs().
|
inline |
Definition at line 371 of file grabcut.h.
References pcl::GrabCut< PointT >::K_.
|
inline |
|
inline |
Returns the number of neighbours to find.
Definition at line 392 of file grabcut.h.
References pcl::GrabCut< PointT >::nb_neighbours_.
|
inline |
Get a pointer to the search method used.
Definition at line 384 of file grabcut.h.
References pcl::GrabCut< PointT >::tree_.
|
protected |
Definition at line 29 of file grabcut.hpp.
References pcl::segmentation::grabcut::SegmentationBackground, and pcl::segmentation::grabcut::TrimapUnknown.
|
protected |
Build the graph for GraphCut.
Definition at line 228 of file grabcut.hpp.
References pcl::GrabCut< PointT >::NLinks::indices, pcl::GrabCut< PointT >::NLinks::nb_links, pcl::segmentation::grabcut::TrimapBackground, pcl::segmentation::grabcut::TrimapUnknown, and pcl::GrabCut< PointT >::NLinks::weights.
|
inlineprotected |
Definition at line 451 of file grabcut.h.
References pcl::GrabCut< PointT >::graph_, and pcl::segmentation::grabcut::BoykovKolmogorov::inSourceTree().
|
virtual |
Run Grabcut refinement on the hard segmentation.
Definition at line 170 of file grabcut.hpp.
|
virtual |
Definition at line 153 of file grabcut.hpp.
References pcl::segmentation::grabcut::learnGMMs().
void pcl::GrabCut< PointT >::setBackgroundPoints | ( | const PointCloudConstPtr & | background_points | ) |
Set background points, foreground points = points \ background points.
void pcl::GrabCut< PointT >::setBackgroundPointsIndices | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 | ||
) |
Set background indices, foreground indices = indices \ background indices.
void pcl::GrabCut< PointT >::setBackgroundPointsIndices | ( | const PointIndicesConstPtr & | indices | ) |
Set background indices, foreground indices = indices \ background indices.
Definition at line 121 of file grabcut.hpp.
References pcl::segmentation::grabcut::SegmentationBackground, pcl::segmentation::grabcut::SegmentationForeground, pcl::segmentation::grabcut::TrimapBackground, and pcl::segmentation::grabcut::TrimapUnknown.
|
virtual |
Provide a pointer to the input dataset.
[in] | cloud | the const boost shared pointer to a PointCloud message |
Reimplemented from pcl::PCLBase< PointT >.
Definition at line 23 of file grabcut.hpp.
|
inline |
Set K parameter to user given value.
Suggested value by the authors is 5
[in] | K | the number of components used in GMM |
Definition at line 376 of file grabcut.h.
References pcl::K, and pcl::GrabCut< PointT >::K_.
|
inline |
Set lambda parameter to user given value.
Suggested value by the authors is 50
[in] | lambda |
Definition at line 368 of file grabcut.h.
References pcl::GrabCut< PointT >::lambda_.
|
inline |
Allows to set the number of neighbours to find.
[in] | number_of_neighbours | new number of neighbours |
Definition at line 389 of file grabcut.h.
References pcl::GrabCut< PointT >::nb_neighbours_.
|
inline |
Provide a pointer to the search object.
tree | a pointer to the spatial search object. |
Definition at line 381 of file grabcut.h.
References pcl::GrabCut< PointT >::tree_.
|
protected |
Set the weights of SOURCE –> v and v –> SINK.
Definition at line 95 of file grabcut.hpp.
|
protected |
Edit Trimap.
Definition at line 210 of file grabcut.hpp.
References pcl::segmentation::grabcut::SegmentationBackground, pcl::segmentation::grabcut::SegmentationForeground, pcl::segmentation::grabcut::TrimapBackground, and pcl::segmentation::grabcut::TrimapForeground.
|
protected |
Definition at line 179 of file grabcut.hpp.
References pcl::segmentation::grabcut::SegmentationBackground, pcl::segmentation::grabcut::SegmentationForeground, pcl::segmentation::grabcut::TrimapBackground, and pcl::segmentation::grabcut::TrimapForeground.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Graph for Graphcut.
Definition at line 483 of file grabcut.h.
Referenced by pcl::GrabCut< PointT >::isSource().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Number of GMM components.
Definition at line 458 of file grabcut.h.
Referenced by pcl::GrabCut< PointT >::getK(), and pcl::GrabCut< PointT >::setK().
|
protected |
|
protected |
lambda = 50. This value was suggested the GrabCut paper.
Definition at line 460 of file grabcut.h.
Referenced by pcl::GrabCut< PointT >::getLambda(), and pcl::GrabCut< PointT >::setLambda().
|
protected |
|
protected |
Number of neighbours.
Definition at line 468 of file grabcut.h.
Referenced by pcl::GrabCut< PointT >::getNumberOfNeighbours(), and pcl::GrabCut< PointT >::setNumberOfNeighbours().
|
protected |
|
protected |
Pointer to the spatial search object.
Definition at line 466 of file grabcut.h.
Referenced by pcl::GrabCut< PointT >::getSearchMethod(), and pcl::GrabCut< PointT >::setSearchMethod().
|
protected |
|
protected |