Update ref and user man

This commit is contained in:
Simon Giraudot 2017-01-09 14:27:03 +01:00
parent 821b26d4e4
commit d43fe019fe
17 changed files with 636 additions and 607 deletions

View File

@ -15,18 +15,18 @@ This component implements a generalization of the algorithm described in \cgalCi
- some analysis is performed on the input data set - some analysis is performed on the input data set
- attributes are computed based on this analysis - attributes are computed based on this analysis
- a set of classification types (for example: ground, building, vegetation) is defined by the user - a set of classification types (for example: ground, building, vegetation) is defined by the user
- attributes are given weights and each pair of attribute/type is assigned a relationship. This can either be done by hand or using training (see \ref Classification_training) - attributes are given weights and each pair of attribute and type is assigned a relationship. This can either be done by hand or using training (see \ref Classification_training)
- classification is computed item-wise by minimizing an energy defined as the sum of the values taken by attributes on input items (which depend on the attribute/type relationship) - classification is computed itemwise by minimizing an energy defined as the sum of the values taken by attributes on input items (which depend on the attribute/type relationship)
- additional regularization can be used by smoothing either locally or globally through an Alpha Expansion approach. - additional regularization can be used by smoothing either locally or globally through an Alpha Expansion approach.
This package is designed to be easily extended by the users: more specifically, attributes and types can be defined by users to handle any data they need to classify (although \cgal provides a predefined framework for common urban scenes).
Currently, \cgal provides data structures to handle classification of point sets.
\cgalFigureBegin{Classification_Organization,organization.png} \cgalFigureBegin{Classification_Organization,organization.png}
Organization of the package. Organization of the package.
\cgalFigureEnd \cgalFigureEnd
This package is designed to be easily extended by users: more specifically, attributes and types can be defined by users to handle any data they need to classify (although \cgal provides a predefined framework for common urban scenes).
Currently, \cgal provides data structures to handle classification of point sets.
\section Classification_structures Data Structures \section Classification_structures Data Structures
\subsection Classification_analysis Analysis \subsection Classification_analysis Analysis
@ -39,7 +39,7 @@ Organization of the package.
- [Local_eigen_analysis](@ref CGAL::Classification::Local_eigen_analysis) precomputes covariance matrices on local neighborhoods of points and stores the associated eigenvectors and eigenvalues - [Local_eigen_analysis](@ref CGAL::Classification::Local_eigen_analysis) precomputes covariance matrices on local neighborhoods of points and stores the associated eigenvectors and eigenvalues
- [Planimetric_grid](@ref CGAL::Classification::Planimetric_grid) is a 2D grid used for digital terrain modeling. - [Planimetric_grid](@ref CGAL::Classification::Planimetric_grid) is a 2D grid used for digital terrain modeling.
The following code snippet shows how to instantiate such data structures from an input PLY point set (the full example is given at the end of the manual). The class `CGAL::Classifier` that handles classification is also instanciated (see \ref Classification_classifier). The following code snippet shows how to instantiate such data structures from an input PLY point set (the full example is given at the end of the manual). The class `CGAL::Classifier` that handles classification is also instantiated (see \ref Classification_classifier).
\snippet Classification/example_classifier.cpp Analysis \snippet Classification/example_classifier.cpp Analysis
@ -56,7 +56,7 @@ Attributes are accessed through `Handle` objects, `CGAL::Classification::Attribu
- [Vertical_dispersion](@ref CGAL::Classification::Attribute::Vertical_dispersion) computes how noisy the point set is on a local Z-cylinder - [Vertical_dispersion](@ref CGAL::Classification::Attribute::Vertical_dispersion) computes how noisy the point set is on a local Z-cylinder
- [Verticality](@ref CGAL::Classification::Attribute::Verticality) compares the local normal vector to the vertical vector. - [Verticality](@ref CGAL::Classification::Attribute::Verticality) compares the local normal vector to the vertical vector.
For more details about how these different attributes can help identifying one classification type or the other, please refer to their associated reference manual pages. In addition, \cgal also provides attributes solely based on the local eigen values \cgalCite{cgal:mbrsh-raofw-11}. Such attributes are more theoretical and harder to relate to a specific use case, but they can help differenciating some classification types: For more details about how these different attributes can help to identify one classification type or the other, please refer to their associated reference manual pages. In addition, \cgal also provides attributes solely based on the local eigen values \cgalCite{cgal:mbrsh-raofw-11}. Such attributes are more theoretical and harder to relate to a specific use case, but they can help to differentiate some classification types:
- [Anisotropy](@ref CGAL::Classification::Attribute::Anisotropy) - [Anisotropy](@ref CGAL::Classification::Attribute::Anisotropy)
- [Eigentropy](@ref CGAL::Classification::Attribute::Eigentropy) - [Eigentropy](@ref CGAL::Classification::Attribute::Eigentropy)
@ -86,7 +86,7 @@ A classification type represents how an item should be classified, for example:
- [NEUTRAL](@ref CGAL::Classification::Attribute::NEUTRAL): the type is not affected by the attribute - [NEUTRAL](@ref CGAL::Classification::Attribute::NEUTRAL): the type is not affected by the attribute
- [PENALIZING](@ref CGAL::Classification::Attribute::PENALIZING): the type is favored by low values of the attribute - [PENALIZING](@ref CGAL::Classification::Attribute::PENALIZING): the type is favored by low values of the attribute
Let \f$x=(x_i)_{i=1..N_c}\f$ be a potential classification result with \f$N_c\f$ the number of input items and \f$x_i\f$ the class of the \f$i^{th}\f$ item (for example: vegetation, ground, etc.). Let \f$a_j(i)\f$ be the raw value of the \f$j^{th}\f$ attribute at the \f$i^{th}\f$ item and \f$w_j\f$ be the weight of this attribute. We define the normalized value of the \f$j^{th}\f$ attribute at the \f$i^{th}\f$ item as follows: Let \f$x=(x_i)_{i=1..N_c}\f$ be a potential classification result with \f$N_c\f$ the number of input items and \f$x_i\f$ the class of the \f$i^{th}\f$ item (for example: vegetation, ground, etc.). Let \f$a_j(i)\f$ be the raw value of the \f$j^{th}\f$ attribute at the \f$i^{th}\f$ item and \f$w_j\f$ be the weight of this attribute. We define the normalized value \f$A_j(x_i) \in [0:1]\f$ of the \f$j^{th}\f$ attribute at the \f$i^{th}\f$ item as follows:
\f{eqnarray*}{ \f{eqnarray*}{
A_j(x_i) = & (1 - \min(\max(0,\frac{a_j(i)}{w_j}), 1)) & \mbox{if } a_j \mbox{ favors } x_i \\ A_j(x_i) = & (1 - \min(\max(0,\frac{a_j(i)}{w_j}), 1)) & \mbox{if } a_j \mbox{ favors } x_i \\
@ -229,7 +229,7 @@ The example \ref Classification_example_training shows how to set inliers and ru
\section Classification_examples Examples \section Classification_examples Examples
\subsection Classification_example_simple Simple classification \subsection Classification_example_general General classification
The following example: The following example:

View File

@ -39,15 +39,15 @@
## Classification ## ## Classification ##
- `CGAL::Classifier<Range, ItemMap>` - `CGAL::Classifier<ItemRange, ItemMap>`
- `CGAL::Point_set_classifier<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Point_set_classifier<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
## Data Structures ## ## Data Structures ##
- `CGAL::Classification::Point_set_neighborhood<Kernel, Range, PointMap>` - `CGAL::Classification::Point_set_neighborhood<Geom_traits, PointRange, PointMap>`
- `CGAL::Classification::Local_eigen_analysis<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Local_eigen_analysis<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Planimetric_grid<Kernel, Range, PointMap>` - `CGAL::Classification::Planimetric_grid<Geom_traits, PointRange, PointMap>`
## Classification Type ## ## Classification Type ##
@ -61,20 +61,20 @@
## Predefined Attributes ## ## Predefined Attributes ##
- `CGAL::Classification::Attribute::Anisotropy<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Anisotropy<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Attribute::Distance_to_plane<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Distance_to_plane<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Attribute::Echo_scatter<Kernel, Range, PointMap, EchoMap>` - `CGAL::Classification::Attribute::Echo_scatter<Geom_traits, PointRange, PointMap, EchoMap>`
- `CGAL::Classification::Attribute::Eigentropy<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Eigentropy<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Attribute::Elevation<Kernel, Range, PointMap>` - `CGAL::Classification::Attribute::Elevation<Geom_traits, PointRange, PointMap>`
- `CGAL::Classification::Attribute::Hsv<Kernel, Range, ColorMap>` - `CGAL::Classification::Attribute::Hsv<Geom_traits, PointRange, ColorMap>`
- `CGAL::Classification::Attribute::Linearity<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Linearity<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Attribute::Omnivariance<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Omnivariance<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Attribute::Planarity<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Planarity<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Attribute::Sphericity<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Sphericity<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Attribute::Sum_eigenvalues<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Sum_eigenvalues<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Attribute::Surface_variation<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Surface_variation<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
- `CGAL::Classification::Attribute::Vertical_dispersion<Kernel, Range, PointMap>` - `CGAL::Classification::Attribute::Vertical_dispersion<Geom_traits, PointRange, PointMap>`
- `CGAL::Classification::Attribute::Verticality<Kernel, Range, PointMap, DiagonalizeTraits>` - `CGAL::Classification::Attribute::Verticality<Geom_traits, PointRange, PointMap, DiagonalizeTraits>`
*/ */

View File

@ -4,3 +4,4 @@ STL_Extension
Algebraic_foundations Algebraic_foundations
Circulator Circulator
Stream_support Stream_support
Solver_interface

View File

@ -33,26 +33,26 @@ namespace Attribute {
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on local distance to a fitted plane. %Attribute based on local distance to a fitted
plane. Characterizing a level of non-planarity can help to
Characterizing a level of non-planarity can help identify noisy identify noisy parts of the input such as vegetation. This
parts of the input such as vegetation. This attribute computes the attribute computes the distance of a point to a locally fitted
distance of a point to a locally fitted plane. plane.
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Distance_to_plane : public Attribute_base class Distance_to_plane : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> distance_to_plane_attribute; std::vector<double> distance_to_plane_attribute;
@ -65,7 +65,7 @@ public:
\param point_map property map to access the input points. \param point_map property map to access the input points.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Distance_to_plane (const Range& input, Distance_to_plane (const PointRange& input,
PointMap point_map, PointMap point_map,
const Local_eigen_analysis& eigen) const Local_eigen_analysis& eigen)
{ {

View File

@ -13,26 +13,25 @@ namespace Attribute {
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on echo scatter. %Attribute based on echo scatter. The number of returns (echo
number) is a useful information provided by most LIDAR sensors. It
can help to identify trees.
The number of returns (echo number) is a useful information \tparam Geom_traits model of \cgal Kernel.
provided by most LIDAR sensors. It can help identify trees. \tparam PointRange model of `ConstRange`. Its iterator type
\tparam Kernel model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam EchoMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `std::size_t`. is `std::size_t`.
*/ */
template <typename Kernel, typename Range, typename PointMap, typename EchoMap> template <typename Geom_traits, typename PointRange, typename PointMap, typename EchoMap>
class Echo_scatter : public Attribute_base class Echo_scatter : public Attribute_base
{ {
public: public:
typedef Classification::Planimetric_grid<Kernel, Range, PointMap> Grid; typedef Classification::Planimetric_grid<Geom_traits, PointRange, PointMap> Grid;
private: private:
typedef Classification::Image<float> Image_float; typedef Classification::Image<float> Image_float;
@ -48,7 +47,7 @@ public:
\param grid_resolution resolution of the planimetric grid. \param grid_resolution resolution of the planimetric grid.
\param radius_neighbors radius of local neighborhoods. \param radius_neighbors radius of local neighborhoods.
*/ */
Echo_scatter (const Range& input, Echo_scatter (const PointRange& input,
EchoMap echo_map, EchoMap echo_map,
Grid& grid, Grid& grid,
const double grid_resolution, const double grid_resolution,

View File

@ -33,39 +33,37 @@ namespace Attribute {
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on the eigenvalues of the covariance matrix %Attribute based on the eigenvalues of the covariance matrix of a
of a local neighborhood. local neighborhood. Linearity is defined, for the 3 eigenvalues
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
Linearity is defined, for the 3 eigenvalues \f$\lambda_1 \ge
\lambda_2 \ge \lambda_3 \ge 0\f$, as:
\f[ \f[
\frac{\lambda_1 - \lambda_2}{\lambda_1} \frac{\lambda_1 - \lambda_2}{\lambda_1}
\f] \f]
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Linearity : public Attribute_base class Linearity : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> attrib; std::vector<double> attrib;
public: public:
/*! /*!
\brief Constructs the attribute. Constructs the attribute.
\param input input range. \param input input range.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Linearity (const Range& input, Linearity (const PointRange& input,
Local_eigen_analysis& eigen) Local_eigen_analysis& eigen)
{ {
this->set_weight(1.); this->set_weight(1.);
@ -94,39 +92,37 @@ public:
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on the eigenvalues of the covariance matrix %Attribute based on the eigenvalues of the covariance matrix of a
of a local neighborhood. local neighborhood. Planarity is defined, for the 3 eigenvalues
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
Planarity is defined, for the 3 eigenvalues \f$\lambda_1 \ge
\lambda_2 \ge \lambda_3 \ge 0\f$, as:
\f[ \f[
\frac{\lambda_2 - \lambda_3}{\lambda_1} \frac{\lambda_2 - \lambda_3}{\lambda_1}
\f] \f]
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Planarity : public Attribute_base class Planarity : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> attrib; std::vector<double> attrib;
public: public:
/*! /*!
\brief Constructs the attribute. Constructs the attribute.
\param input input range. \param input input range.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Planarity (const Range& input, Planarity (const PointRange& input,
Local_eigen_analysis& eigen) Local_eigen_analysis& eigen)
{ {
this->set_weight(1.); this->set_weight(1.);
@ -154,39 +150,37 @@ public:
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on the eigenvalues of the covariance matrix %Attribute based on the eigenvalues of the covariance matrix of a
of a local neighborhood. local neighborhood. Sphericity is defined, for the 3 eigenvalues
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
Sphericity is defined, for the 3 eigenvalues \f$\lambda_1 \ge
\lambda_2 \ge \lambda_3 \ge 0\f$, as:
\f[ \f[
\frac{\lambda_3}{\lambda_1} \frac{\lambda_3}{\lambda_1}
\f] \f]
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Sphericity : public Attribute_base class Sphericity : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> attrib; std::vector<double> attrib;
public: public:
/*! /*!
\brief Constructs the attribute. Constructs the attribute.
\param input input range. \param input input range.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Sphericity (const Range& input, Sphericity (const PointRange& input,
Local_eigen_analysis& eigen) Local_eigen_analysis& eigen)
{ {
this->set_weight(1.); this->set_weight(1.);
@ -213,39 +207,37 @@ public:
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on the eigenvalues of the covariance matrix %Attribute based on the eigenvalues of the covariance matrix of a
of a local neighborhood. local neighborhood. Omnivariance is defined, for the 3 eigenvalues
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
Omnivariance is defined, for the 3 eigenvalues \f$\lambda_1 \ge
\lambda_2 \ge \lambda_3 \ge 0\f$, as:
\f[ \f[
(\lambda_1 \times \lambda_2 \times \lambda_3)^{\frac{1}{3}} (\lambda_1 \times \lambda_2 \times \lambda_3)^{\frac{1}{3}}
\f] \f]
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Omnivariance : public Attribute_base class Omnivariance : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> attrib; std::vector<double> attrib;
public: public:
/*! /*!
\brief Constructs the attribute. Constructs the attribute.
\param input input range. \param input input range.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Omnivariance (const Range& input, Omnivariance (const PointRange& input,
Local_eigen_analysis& eigen) Local_eigen_analysis& eigen)
{ {
this->set_weight(1.); this->set_weight(1.);
@ -269,39 +261,37 @@ public:
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on the eigenvalues of the covariance matrix %Attribute based on the eigenvalues of the covariance matrix of a
of a local neighborhood. local neighborhood. Anisotropy is defined, for the 3 eigenvalues
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
Anisotropy is defined, for the 3 eigenvalues \f$\lambda_1 \ge
\lambda_2 \ge \lambda_3 \ge 0\f$, as:
\f[ \f[
\frac{\lambda_1 - \lambda_3}{\lambda_1} \frac{\lambda_1 - \lambda_3}{\lambda_1}
\f] \f]
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Anisotropy : public Attribute_base class Anisotropy : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> attrib; std::vector<double> attrib;
public: public:
/*! /*!
\brief Constructs the attribute. Constructs the attribute.
\param input input range. \param input input range.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Anisotropy (const Range& input, Anisotropy (const PointRange& input,
Local_eigen_analysis& eigen) Local_eigen_analysis& eigen)
{ {
this->set_weight(1.); this->set_weight(1.);
@ -328,39 +318,37 @@ public:
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on the eigenvalues of the covariance matrix %Attribute based on the eigenvalues of the covariance matrix of a
of a local neighborhood. local neighborhood. Eigentropy is defined, for the 3 eigenvalues
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
Eigentropy is defined, for the 3 eigenvalues \f$\lambda_1 \ge
\lambda_2 \ge \lambda_3 \ge 0\f$, as:
\f[ \f[
- \sum_{i=1}^3 \lambda_i \times \log{\lambda_i} - \sum_{i=1}^3 \lambda_i \times \log{\lambda_i}
\f] \f]
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Eigentropy : public Attribute_base class Eigentropy : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> attrib; std::vector<double> attrib;
public: public:
/*! /*!
\brief Constructs the attribute. Constructs the attribute.
\param input input range. \param input input range.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Eigentropy (const Range& input, Eigentropy (const PointRange& input,
Local_eigen_analysis& eigen) Local_eigen_analysis& eigen)
{ {
this->set_weight(1.); this->set_weight(1.);
@ -391,39 +379,38 @@ public:
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on the eigenvalues of the covariance matrix %Attribute based on the eigenvalues of the covariance matrix of a
of a local neighborhood. local neighborhood. The sum of the eigenvalues is defined, for the
3 eigenvalues \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$,
The sum of the eigenvalues is defined, for the 3 eigenvalues as:
\f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
\f[ \f[
\lambda_1 + \lambda_2 + \lambda_3 \lambda_1 + \lambda_2 + \lambda_3
\f] \f]
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Sum_eigenvalues : public Attribute_base class Sum_eigenvalues : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> attrib; std::vector<double> attrib;
public: public:
/*! /*!
\brief Constructs the attribute. Constructs the attribute.
\param input input range. \param input input range.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Sum_eigenvalues (const Range& input, Sum_eigenvalues (const PointRange& input,
Local_eigen_analysis& eigen) Local_eigen_analysis& eigen)
{ {
this->set_weight(1.); this->set_weight(1.);
@ -445,39 +432,38 @@ public:
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on the eigenvalues of the covariance matrix %Attribute based on the eigenvalues of the covariance
of a local neighborhood. matrix of a local neighborhood. Surface variation is defined, for
the 3 eigenvalues \f$\lambda_1 \ge \lambda_2 \ge \lambda_3 \ge
Surface variation is defined, for the 3 eigenvalues \f$\lambda_1 0\f$, as:
\ge \lambda_2 \ge \lambda_3 \ge 0\f$, as:
\f[ \f[
\frac{\lambda_3}{\lambda_1 + \lambda_2 + \lambda_3} \frac{\lambda_3}{\lambda_1 + \lambda_2 + \lambda_3}
\f] \f]
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Surface_variation : public Attribute_base class Surface_variation : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> attrib; std::vector<double> attrib;
public: public:
/*! /*!
\brief Constructs the attribute. Constructs the attribute.
\param input input range. \param input input range.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Surface_variation (const Range& input, Surface_variation (const PointRange& input,
Local_eigen_analysis& eigen) Local_eigen_analysis& eigen)
{ {
this->set_weight(1.); this->set_weight(1.);

View File

@ -35,29 +35,26 @@ namespace Attribute {
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on local elevation. %Attribute based on local elevation. The local position of the
ground can be computed for urban scenes. This attribute computes
the distance to the local estimation of the ground. It is useful
to discriminate the ground from horizontal roofs.
The local position of the ground can be computed for urban \tparam Geom_traits model of \cgal Kernel.
scenes. This attribute computes the distance to the local \tparam PointRange model of `ConstRange`. Its iterator type
estimation of the ground.
It is useful to discriminate the ground from horizontal roofs.
\tparam Kernel model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
*/ */
template <typename Kernel, typename Range, typename PointMap> template <typename Geom_traits, typename PointRange, typename PointMap>
class Elevation : public Attribute_base class Elevation : public Attribute_base
{ {
typedef typename Kernel::Iso_cuboid_3 Iso_cuboid_3; typedef typename Geom_traits::Iso_cuboid_3 Iso_cuboid_3;
typedef Image<float> Image_float; typedef Image<float> Image_float;
typedef Planimetric_grid<Kernel, Range, PointMap> Grid; typedef Planimetric_grid<Geom_traits, PointRange, PointMap> Grid;
std::vector<double> elevation_attribute; std::vector<double> elevation_attribute;
@ -69,10 +66,10 @@ public:
\param point_map property map to access the input points. \param point_map property map to access the input points.
\param grid precomputed `Planimetric_grid`. \param grid precomputed `Planimetric_grid`.
\param grid_resolution resolution of the planimetric grid. \param grid_resolution resolution of the planimetric grid.
\param radius_dtm radius for digital terrain modeling (must be bigger than the size of a building). \param radius_dtm radius for digital terrain modeling (should be
larger than the width and length of the largest building).
*/ */
Elevation (const Range& input, Elevation (const PointRange& input,
PointMap point_map, PointMap point_map,
const Grid& grid, const Grid& grid,
const double grid_resolution, const double grid_resolution,

View File

@ -33,29 +33,40 @@ namespace Attribute {
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on HSV colorimetric information. %Attribute based on HSV colorimetric information. If the input
point cloud has colorimetric information, it can be used for
classification purposes. This attribute is based on a Gaussian
probabilistic model on one of the three HSV channels (hue,
saturation or value). It computes the probability of the color of
the input point to match this specific color channel defined by a
mean and a standard deviation.
If the input point cloud has colorimetric information, it can be The HSV channels are defined this way:
used for classification purposes. This attribute is based on a
Gaussian probabilistic model on one of the three HSV channels
(hue, saturation or value).
It computes the probability of the color of the input point to - Hue ranges from 0 to 360 and measures the general "tint" of the
match this specific color channel defined by a mean and a standard color (green, blue, pink, etc.)
deviation.
- Saturation ranges from 0 to 100 and measures the "strength" of the
color (0 is gray and 100 is the fully saturated color)
- Value ranges from 0 to 100 and measures the "brightness" of the
color (0 is black and 100 is the fully bright color)
For example, such an attribute using the channel 0 (hue) with a For example, such an attribute using the channel 0 (hue) with a
mean of 90 (which corresponds to a green hue) can help identify mean of 90 (which corresponds to a green hue) can help to identify
trees. trees.
\note The user only needs to provide a map to standard (and more common)
RGB colors, the conversion to HSV is done internally.
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam ColorMap model of `ReadablePropertyMap` whose key \tparam ColorMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `CGAL::Classification::RGB_Color`. is `CGAL::Classification::RGB_Color`.
*/ */
template <typename Kernel, typename Range, typename ColorMap> template <typename Geom_traits, typename PointRange, typename ColorMap>
class Hsv : public Attribute_base class Hsv : public Attribute_base
{ {
typedef typename Classification::RGB_Color RGB_Color; typedef typename Classification::RGB_Color RGB_Color;
@ -77,7 +88,7 @@ public:
\param mean mean value of the specified channel. \param mean mean value of the specified channel.
\param sd standard deviation of the specified channel. \param sd standard deviation of the specified channel.
*/ */
Hsv (const Range& input, Hsv (const PointRange& input,
ColorMap color_map, ColorMap color_map,
std::size_t channel, std::size_t channel,
double mean, double sd) double mean, double sd)

View File

@ -34,27 +34,26 @@ namespace Attribute {
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on local vertical dispersion of points. %Attribute based on local vertical dispersion of points. Urban
scenes can often be decomposed as a set of 2D regions with
Urban scenes can often be decomposed as a set of 2D regions with
different heights. While these heights are usually piecewise different heights. While these heights are usually piecewise
constant or piecewise linear, on some specific parts of the scene constant or piecewise linear, on some specific parts of the scene
such as vegetation, they can become extremely unstable. This such as vegetation, they can become extremely unstable. This
attribute quantifies the vertical dispersion of the points on a attribute quantifies the vertical dispersion of the points on a
local Z-cylinder around the points. local Z-cylinder around the points.
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
*/ */
template <typename Kernel, typename Range, typename PointMap> template <typename Geom_traits, typename PointRange, typename PointMap>
class Vertical_dispersion : public Attribute_base class Vertical_dispersion : public Attribute_base
{ {
typedef Classification::Image<float> Image_float; typedef Classification::Image<float> Image_float;
typedef Classification::Planimetric_grid<Kernel, Range, PointMap> Grid; typedef Classification::Planimetric_grid<Geom_traits, PointRange, PointMap> Grid;
std::vector<double> vertical_dispersion; std::vector<double> vertical_dispersion;
public: public:
@ -67,7 +66,7 @@ public:
\param grid_resolution resolution of the planimetric grid. \param grid_resolution resolution of the planimetric grid.
\param radius_neighbors radius of local neighborhoods. \param radius_neighbors radius of local neighborhoods.
*/ */
Vertical_dispersion (const Range& input, Vertical_dispersion (const PointRange& input,
PointMap point_map, PointMap point_map,
const Grid& grid, const Grid& grid,
const double grid_resolution, const double grid_resolution,
@ -83,7 +82,7 @@ public:
Dispersion(i,j)=0; Dispersion(i,j)=0;
std::size_t square = (std::size_t)(0.5 * radius_neighbors / grid_resolution) + 1; std::size_t square = (std::size_t)(0.5 * radius_neighbors / grid_resolution) + 1;
typename Kernel::Vector_3 verti (0., 0., 1.); typename Geom_traits::Vector_3 verti (0., 0., 1.);
for (std::size_t j = 0; j < grid.height(); j++){ for (std::size_t j = 0; j < grid.height(); j++){
for (std::size_t i = 0; i < grid.width(); i++){ for (std::size_t i = 0; i < grid.width(); i++){

View File

@ -33,26 +33,26 @@ namespace Attribute {
/*! /*!
\ingroup PkgClassificationAttributes \ingroup PkgClassificationAttributes
\brief Attribute based on local verticality. %Attribute based on local verticality. The orientation of the
local tangent plane of the considered point can be useful to
discriminate facades from the ground. This attribute can use
normal vectors if available or eigen analysis that estimates
tangent planes from local neighborhoods.
The orientation of the best fitting plane of a local neighborhood \tparam Geom_traits model of \cgal Kernel.
of the considered point can be useful to discriminate facades from \tparam PointRange model of `ConstRange`. Its iterator type
the ground.
\tparam Kernel model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type
is `RandomAccessIterator`. is `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Verticality : public Attribute_base class Verticality : public Attribute_base
{ {
typedef Classification::Local_eigen_analysis<Kernel, Range, typedef Classification::Local_eigen_analysis<Geom_traits, PointRange,
PointMap, DiagonalizeTraits> Local_eigen_analysis; PointMap, DiagonalizeTraits> Local_eigen_analysis;
std::vector<double> verticality_attribute; std::vector<double> verticality_attribute;
@ -63,15 +63,15 @@ public:
\param input input range. \param input input range.
\param eigen class with precomputed eigenvectors and eigenvalues. \param eigen class with precomputed eigenvectors and eigenvalues.
*/ */
Verticality (const Range& input, Verticality (const PointRange& input,
const Local_eigen_analysis& eigen) const Local_eigen_analysis& eigen)
{ {
this->set_weight(1.); this->set_weight(1.);
typename Kernel::Vector_3 vertical (0., 0., 1.); typename Geom_traits::Vector_3 vertical (0., 0., 1.);
for (std::size_t i = 0; i < input.size(); i++) for (std::size_t i = 0; i < input.size(); i++)
{ {
typename Kernel::Vector_3 normal = eigen.normal_vector(i); typename Geom_traits::Vector_3 normal = eigen.normal_vector(i);
normal = normal / CGAL::sqrt (normal * normal); normal = normal / CGAL::sqrt (normal * normal);
verticality_attribute.push_back (1. - CGAL::abs(normal * vertical)); verticality_attribute.push_back (1. - CGAL::abs(normal * vertical));
} }
@ -84,21 +84,21 @@ public:
\brief Constructs the attribute using provided normals of points. \brief Constructs the attribute using provided normals of points.
\tparam VectorMap model of `ReadablePropertyMap` whose key \tparam VectorMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Vector_3<Kernel>`. is `Geom_traits::Vector_3`.
\param input input range. \param input input range.
\param normal_map property map to access the normal vectors of the input points. \param normal_map property map to access the normal vectors of the input points.
*/ */
template <typename VectorMap> template <typename VectorMap>
Verticality (const Range& input, Verticality (const PointRange& input,
VectorMap normal_map) VectorMap normal_map)
{ {
this->set_weight(1.); this->set_weight(1.);
typename Kernel::Vector_3 vertical (0., 0., 1.); typename Geom_traits::Vector_3 vertical (0., 0., 1.);
for (std::size_t i = 0; i < input.size(); i++) for (std::size_t i = 0; i < input.size(); i++)
{ {
typename Kernel::Vector_3 normal = get(normal_map, *(input.begin()+i)); typename Geom_traits::Vector_3 normal = get(normal_map, *(input.begin()+i));
normal = normal / CGAL::sqrt (normal * normal); normal = normal / CGAL::sqrt (normal * normal);
verticality_attribute.push_back (1. - std::fabs(normal * vertical)); verticality_attribute.push_back (1. - std::fabs(normal * vertical));
} }

View File

@ -107,7 +107,7 @@ public:
/*! /*!
\ingroup PkgClassification \ingroup PkgClassification
\brief Handle to an `Attribute_base`. \brief %Handle to an `Attribute_base`.
\cgalModels Handle \cgalModels Handle
*/ */

View File

@ -20,23 +20,23 @@ namespace Classification {
eigenvalues of the covariance matrices of all points of a point eigenvalues of the covariance matrices of all points of a point
set using a local neighborhood. set using a local neighborhood.
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type is
is `RandomAccessIterator`. `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, typename Range, typename PointMap, template <typename Geom_traits, typename PointRange, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Local_eigen_analysis class Local_eigen_analysis
{ {
public: public:
typedef typename Kernel::Point_3 Point; typedef typename Geom_traits::Point_3 Point;
typedef typename Kernel::Vector_3 Vector; typedef typename Geom_traits::Vector_3 Vector;
typedef typename Kernel::Plane_3 Plane; typedef typename Geom_traits::Plane_3 Plane;
typedef CGAL::cpp11::array<double, 3> Eigenvalues; ///< Eigenvalues (sorted in ascending order) typedef CGAL::cpp11::array<double, 3> Eigenvalues; ///< Eigenvalues (sorted in ascending order)
@ -68,7 +68,7 @@ public:
\param neighbor_query object used to access neighborhoods of points. \param neighbor_query object used to access neighborhoods of points.
*/ */
template <typename NeighborQuery> template <typename NeighborQuery>
Local_eigen_analysis (const Range& input, Local_eigen_analysis (const PointRange& input,
PointMap point_map, PointMap point_map,
const NeighborQuery& neighbor_query) const NeighborQuery& neighbor_query)
{ {

View File

@ -19,20 +19,20 @@ namespace Classification {
projection along the Z-axis lies within this cell. The mapping projection along the Z-axis lies within this cell. The mapping
from each point to the cell it lies in is also stored. from each point to the cell it lies in is also stored.
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type is
is `RandomAccessIterator`. `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
*/ */
template <typename Kernel, typename Range, typename PointMap> template <typename Geom_traits, typename PointRange, typename PointMap>
class Planimetric_grid class Planimetric_grid
{ {
public: public:
typedef typename Kernel::Point_3 Point_3; typedef typename Geom_traits::Point_3 Point_3;
typedef typename Kernel::Iso_cuboid_3 Iso_cuboid_3; typedef typename Geom_traits::Iso_cuboid_3 Iso_cuboid_3;
private: private:
typedef Image<std::vector<std::size_t> > Image_indices; typedef Image<std::vector<std::size_t> > Image_indices;
@ -56,7 +56,7 @@ public:
\param bbox bounding box of the input range. \param bbox bounding box of the input range.
\param grid_resolution resolution of the planimetric grid. \param grid_resolution resolution of the planimetric grid.
*/ */
Planimetric_grid (const Range& input, Planimetric_grid (const PointRange& input,
PointMap point_map, PointMap point_map,
const Iso_cuboid_3& bbox, const Iso_cuboid_3& bbox,
const double grid_resolution) const double grid_resolution)

View File

@ -22,8 +22,8 @@ namespace Classification {
\ingroup PkgClassificationDataStructures \ingroup PkgClassificationDataStructures
\brief Class that precomputes spatial searching structures for an \brief Class that precomputes spatial searching structures for an
input point set and gives easy access to local neighborhoods of input point set and gives access to the local neighborhood of a
points. point as a set of indices.
It allows the user to generate models of `NeighborQuery` based on It allows the user to generate models of `NeighborQuery` based on
a fixed range neighborhood or on a fixed K number of neighbors. In a fixed range neighborhood or on a fixed K number of neighbors. In
@ -31,22 +31,22 @@ namespace Classification {
simplified version of the point set to allow for neighbor queries simplified version of the point set to allow for neighbor queries
at a higher scale. at a higher scale.
\tparam Kernel is a model of \cgal Kernel. \tparam Geom_traits is a model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type is
is `RandomAccessIterator`. `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
*/ */
template <typename Kernel, typename Range, typename PointMap> template <typename Geom_traits, typename PointRange, typename PointMap>
class Point_set_neighborhood class Point_set_neighborhood
{ {
typedef typename Kernel::FT FT; typedef typename Geom_traits::FT FT;
typedef typename Kernel::Point_3 Point; typedef typename Geom_traits::Point_3 Point;
class My_point_property_map{ class My_point_property_map{
const Range* input; const PointRange* input;
PointMap point_map; PointMap point_map;
public: public:
@ -55,14 +55,14 @@ class Point_set_neighborhood
typedef std::size_t key_type; typedef std::size_t key_type;
typedef boost::lvalue_property_map_tag category; typedef boost::lvalue_property_map_tag category;
My_point_property_map () { } My_point_property_map () { }
My_point_property_map (const Range *input, PointMap point_map) My_point_property_map (const PointRange *input, PointMap point_map)
: input (input), point_map (point_map) { } : input (input), point_map (point_map) { }
reference operator[] (key_type k) const { return get(point_map, *(input->begin()+k)); } reference operator[] (key_type k) const { return get(point_map, *(input->begin()+k)); }
friend inline reference get (const My_point_property_map& ppmap, key_type i) friend inline reference get (const My_point_property_map& ppmap, key_type i)
{ return ppmap[i]; } { return ppmap[i]; }
}; };
typedef Search_traits_3<Kernel> SearchTraits_3; typedef Search_traits_3<Geom_traits> SearchTraits_3;
typedef Search_traits_adapter <std::size_t, My_point_property_map, SearchTraits_3> Search_traits; typedef Search_traits_adapter <std::size_t, My_point_property_map, SearchTraits_3> Search_traits;
typedef Sliding_midpoint<Search_traits> Splitter; typedef Sliding_midpoint<Search_traits> Splitter;
typedef Distance_adapter<std::size_t, My_point_property_map, Euclidean_distance<SearchTraits_3> > Distance; typedef Distance_adapter<std::size_t, My_point_property_map, Euclidean_distance<SearchTraits_3> > Distance;
@ -102,9 +102,10 @@ public:
/// \cond SKIP_IN_MANUAL /// \cond SKIP_IN_MANUAL
template <typename OutputIterator> template <typename OutputIterator>
void operator() (const value_type& query, OutputIterator output) const OutputIterator operator() (const value_type& query, OutputIterator output) const
{ {
neighborhood.k_neighbors (query, k, output); neighborhood.k_neighbors (query, k, output);
return output;
} }
/// \endcond /// \endcond
}; };
@ -134,9 +135,10 @@ public:
/// \cond SKIP_IN_MANUAL /// \cond SKIP_IN_MANUAL
template <typename OutputIterator> template <typename OutputIterator>
void operator() (const value_type& query, OutputIterator output) const OutputIterator operator() (const value_type& query, OutputIterator output) const
{ {
neighborhood.range_neighbors (query, radius, output); neighborhood.range_neighbors (query, radius, output);
return output;
} }
/// \endcond /// \endcond
}; };
@ -154,7 +156,7 @@ public:
\param input input range. \param input input range.
\param point_map property map to access the input points. \param point_map property map to access the input points.
*/ */
Point_set_neighborhood (const Range& input, Point_set_neighborhood (const PointRange& input,
PointMap point_map) PointMap point_map)
: m_tree (NULL) : m_tree (NULL)
{ {
@ -179,7 +181,7 @@ public:
\param point_map property map to access the input points. \param point_map property map to access the input points.
\param voxel_size size of the cells of the 3D grid used for simplification. \param voxel_size size of the cells of the 3D grid used for simplification.
*/ */
Point_set_neighborhood (const Range& input, Point_set_neighborhood (const PointRange& input,
PointMap point_map, PointMap point_map,
double voxel_size) double voxel_size)
: m_tree (NULL) : m_tree (NULL)

View File

@ -77,7 +77,7 @@ public:
/*! /*!
\ingroup PkgClassification \ingroup PkgClassification
\brief Handle to a classification `Type`. \brief %Handle to a classification `Type`.
\cgalModels Handle \cgalModels Handle
*/ */

View File

@ -62,43 +62,41 @@ namespace CGAL {
classification types. classification types.
This class implements the core of the classification algorithm This class implements the core of the classification algorithm
\cgalCite{cgal:lm-clscm-12}. It uses a data set as input and assignes \cgalCite{cgal:lm-clscm-12}. It uses a data set as input and assigns
each input item to a classification type among a set of user each input item to a classification type among a set of user defined
defined classification types. classification types. To achieve this classification, a set of local
geometric attributes are used, such as planarity, elevation or
To achieve this classification algorithm, a set of local geometric vertical dispersion. In addition, the user must define a set of
attributes are used, such as planarity, elevation or vertical classification types such as building, ground or vegetation.
dispersion. In addition, the user must define a set of classification
types such as building, ground or vegetation.
Each pair of attribute and type must be assigned an Each pair of attribute and type must be assigned an
[Attribute::Effect](@ref CGAL::Classification::Attribute::Effect) (for [Attribute::Effect](@ref CGAL::Classification::Attribute::Effect) (for
example, vegetation has a low planarity and a high vertical example, vegetation has a low planarity and a high vertical
dispersion) and each attribute must be assigned a weight. These dispersion) and each attribute must be assigned a weight. These
parameters can be set up by hand or by automatic training, provided a parameters can be set up by hand or by automatic training, provided a
small user defined set of inlier is given for each classification small user-defined set of inlier is given for each classification
type. type.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam ItemRange model of `ConstRange`. Its iterator type is
is `RandomAccessIterator`. `RandomAccessIterator`.
\tparam ItemMap model of `ReadablePropertyMap` whose key \tparam ItemMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type is type is the value type of the iterator of `ItemRange` and value type is
the type of the items that are classified. the type of the items that are classified.
*/ */
template <typename Range, template <typename ItemRange,
typename ItemMap> typename ItemMap>
class Classifier class Classifier
{ {
public: public:
/// \cond SKIP_IN_MANUAL
typedef typename ItemMap::value_type Item;
typedef typename Classification::Type_handle Type_handle; typedef typename Classification::Type_handle Type_handle;
typedef typename Classification::Attribute_handle Attribute_handle; typedef typename Classification::Attribute_handle Attribute_handle;
/// \cond SKIP_IN_MANUAL
typedef typename ItemMap::value_type Item;
#ifdef CGAL_DO_NOT_USE_BOYKOV_KOLMOGOROV_MAXFLOW_SOFTWARE #ifdef CGAL_DO_NOT_USE_BOYKOV_KOLMOGOROV_MAXFLOW_SOFTWARE
typedef internal::Alpha_expansion_graph_cut_boost Alpha_expansion; typedef internal::Alpha_expansion_graph_cut_boost Alpha_expansion;
#else #else
@ -107,7 +105,7 @@ public:
protected: protected:
const Range& m_input; const ItemRange& m_input;
ItemMap m_item_map; ItemMap m_item_map;
std::vector<std::size_t> m_assigned_type; std::vector<std::size_t> m_assigned_type;
@ -135,7 +133,7 @@ public:
\param item_map property map to access the input items. \param item_map property map to access the input items.
*/ */
Classifier (const Range& input, Classifier (const ItemRange& input,
ItemMap item_map) ItemMap item_map)
: m_input (input), m_item_map (item_map) : m_input (input), m_item_map (item_map)
{ {
@ -147,6 +145,195 @@ public:
virtual ~Classifier() { } virtual ~Classifier() { }
/// \endcond /// \endcond
/// \name Attributes
/// @{
/*!
\brief Adds an attribute.
\tparam Attribute type of the attribute, inherited from
`Classification::Attribute_base`.
\tparam T types of the parameters of the attribute's constructor.
\param t parameters of the attribute's constructor.
\return a handle to the newly added attribute.
*/
#if (!defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES) && !defined(CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE)) || DOXYGEN_RUNNING
template <typename Attribute, typename ... T>
Attribute_handle add_attribute (T&& ... t)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, std::forward<T>(t)...)));
return m_attributes.back();
}
#else
template <typename Attribute>
Attribute_handle add_attribute ()
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input)));
return m_attributes.back();
}
template <typename Attribute, typename T1>
Attribute_handle add_attribute (T1& t1)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1)));
return m_attributes.back();
}
template <typename Attribute, typename T1, typename T2>
Attribute_handle add_attribute (T1& t1, T2& t2)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1, t2)));
return m_attributes.back();
}
template <typename Attribute, typename T1, typename T2, typename T3>
Attribute_handle add_attribute (T1& t1, T2& t2, T3& t3)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1, t2, t3)));
return m_attributes.back();
}
template <typename Attribute, typename T1, typename T2, typename T3, typename T4>
Attribute_handle add_attribute (T1& t1, T2& t2, T3& t3, T4& t4)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1, t2, t3, t4)));
return m_attributes.back();
}
template <typename Attribute, typename T1, typename T2, typename T3, typename T4, typename T5>
Attribute_handle add_attribute (T1& t1, T2& t2, T3& t3, T4& t4, T5& t5)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1, t2, t3, t4, t5)));
return m_attributes.back();
}
#endif
/*!
\brief Removes an attribute.
\param attribute the handle to attribute type that must be removed.
\return `true` if the attribute was correctly removed, `false` if
its handle was not found.
*/
bool remove_attribute (Attribute_handle attribute)
{
for (std::size_t i = 0; i < m_attributes.size(); ++ i)
if (m_attributes[i] == attribute)
{
m_attributes.erase (m_attributes.begin() + i);
return true;
}
return false;
}
/*!
\brief Returns how many attributes are defined.
*/
std::size_t number_of_attributes() const
{
return m_attributes.size();
}
/*!
\brief Removes all attributes.
*/
void clear_attributes ()
{
m_attributes.clear();
}
/// \cond SKIP_IN_MANUAL
Attribute_handle get_attribute(std::size_t index)
{
return m_attributes[index];
}
/// \endcond
/// @}
/// \name Classification Types
/// @{
/*!
\brief Adds a classification type.
\param name name of the classification type.
\return a handle to the newly added classification type.
*/
Type_handle add_classification_type (const char* name)
{
Type_handle out (new Classification::Type (name));
m_types.push_back (out);
return out;
}
/*!
\brief Removes a classification type.
\param type the handle to the classification type that must be removed.
\return `true` if the classification type was correctly removed,
`false` if its handle was not found.
*/
bool remove_classification_type (Type_handle type)
{
std::size_t idx = (std::size_t)(-1);
for (std::size_t i = 0; i < m_types.size(); ++ i)
if (m_types[i] == type)
{
m_types.erase (m_types.begin() + i);
idx = i;
break;
}
if (idx == (std::size_t)(-1))
return false;
std::cerr << idx << std::endl;
for (std::size_t i = 0; i < m_assigned_type.size(); ++ i)
if (m_assigned_type[i] == (std::size_t)(-1))
continue;
else if (m_assigned_type[i] > idx)
m_assigned_type[i] --;
else if (m_assigned_type[i] == idx)
m_assigned_type[i] = (std::size_t)(-1);
for (std::size_t i = 0; i < m_training_type.size(); ++ i)
if (m_assigned_type[i] == (std::size_t)(-1))
continue;
else if (m_training_type[i] > idx)
m_training_type[i] --;
else if (m_training_type[i] == idx)
m_training_type[i] = (std::size_t)(-1);
return true;
}
/*!
\brief Returns how many classification types are defined.
*/
std::size_t number_of_classification_types () const
{
return m_types.size();
}
/// \cond SKIP_IN_MANUAL
Type_handle get_classification_type (std::size_t index)
{
return m_types[index];
}
/// \endcond
/*!
\brief Removes all classification types.
*/
void clear_classification_types ()
{
m_types.clear();
}
/// @}
/// \name Classification /// \name Classification
/// @{ /// @{
@ -271,7 +458,7 @@ public:
*/ */
template <typename NeighborQuery> template <typename NeighborQuery>
void run_with_graphcut (const NeighborQuery& neighbor_query, void run_with_graphcut (const NeighborQuery& neighbor_query,
const double& weight) const double weight)
{ {
prepare_classification (); prepare_classification ();
@ -321,196 +508,6 @@ public:
/// \name Classification Types
/// @{
/*!
\brief Adds a classification type.
\param name name of the classification type.
\return a handle to the newly added classification type.
*/
Type_handle add_classification_type (const char* name)
{
Type_handle out (new Classification::Type (name));
m_types.push_back (out);
return out;
}
/*!
\brief Removes a classification type.
\param type the handle to the classification type that must be removed.
\return `true` if the classification type was correctly removed,
`false` if its handle was not found.
*/
bool remove_classification_type (Type_handle type)
{
std::size_t idx = (std::size_t)(-1);
for (std::size_t i = 0; i < m_types.size(); ++ i)
if (m_types[i] == type)
{
m_types.erase (m_types.begin() + i);
idx = i;
break;
}
if (idx == (std::size_t)(-1))
return false;
std::cerr << idx << std::endl;
for (std::size_t i = 0; i < m_assigned_type.size(); ++ i)
if (m_assigned_type[i] == (std::size_t)(-1))
continue;
else if (m_assigned_type[i] > idx)
m_assigned_type[i] --;
else if (m_assigned_type[i] == idx)
m_assigned_type[i] = (std::size_t)(-1);
for (std::size_t i = 0; i < m_training_type.size(); ++ i)
if (m_assigned_type[i] == (std::size_t)(-1))
continue;
else if (m_training_type[i] > idx)
m_training_type[i] --;
else if (m_training_type[i] == idx)
m_training_type[i] = (std::size_t)(-1);
return true;
}
/*!
\brief Returns how many classification types are defined.
*/
std::size_t number_of_classification_types () const
{
return m_types.size();
}
/// \cond SKIP_IN_MANUAL
Type_handle get_classification_type (std::size_t idx)
{
return m_types[idx];
}
/// \endcond
/*!
\brief Removes all classification types.
*/
void clear_classification_types ()
{
m_types.clear();
}
/// @}
/// \name Attributes
/// @{
/*!
\brief Adds an attribute.
\tparam Attribute type of the attribute, inherited from
`Classification::Attribute_base`.
\tparam T types of the parameters of the attribute's constructor.
\param t parameters of the attribute's constructor.
\return a handle to the newly added attribute.
*/
#if (!defined(CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES) && !defined(CGAL_CFG_NO_CPP0X_RVALUE_REFERENCE)) || DOXYGEN_RUNNING
template <typename Attribute, typename ... T>
Attribute_handle add_attribute (T&& ... t)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, std::forward<T>(t)...)));
return m_attributes.back();
}
#else
template <typename Attribute>
Attribute_handle add_attribute ()
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input)));
return m_attributes.back();
}
template <typename Attribute, typename T1>
Attribute_handle add_attribute (T1& t1)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1)));
return m_attributes.back();
}
template <typename Attribute, typename T1, typename T2>
Attribute_handle add_attribute (T1& t1, T2& t2)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1, t2)));
return m_attributes.back();
}
template <typename Attribute, typename T1, typename T2, typename T3>
Attribute_handle add_attribute (T1& t1, T2& t2, T3& t3)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1, t2, t3)));
return m_attributes.back();
}
template <typename Attribute, typename T1, typename T2, typename T3, typename T4>
Attribute_handle add_attribute (T1& t1, T2& t2, T3& t3, T4& t4)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1, t2, t3, t4)));
return m_attributes.back();
}
template <typename Attribute, typename T1, typename T2, typename T3, typename T4, typename T5>
Attribute_handle add_attribute (T1& t1, T2& t2, T3& t3, T4& t4, T5& t5)
{
m_attributes.push_back (Attribute_handle (new Attribute(m_input, t1, t2, t3, t4, t5)));
return m_attributes.back();
}
#endif
/*!
\brief Removes an attribute.
\param attribute the handle to attribute type that must be removed.
\return `true` if the attribute was correctly removed, `false` if
its handle was not found.
*/
bool remove_attribute (Attribute_handle attribute)
{
for (std::size_t i = 0; i < m_attributes.size(); ++ i)
if (m_attributes[i] == attribute)
{
m_attributes.erase (m_attributes.begin() + i);
return true;
}
return false;
}
/*!
\brief Returns how many attributes are defined.
*/
std::size_t number_of_attributes() const
{
return m_attributes.size();
}
/*!
\brief Removes all attributes.
*/
void clear_attributes ()
{
m_attributes.clear();
}
/// \cond SKIP_IN_MANUAL
Attribute_handle get_attribute(std::size_t idx)
{
return m_attributes[idx];
}
/// \endcond
/// @}
/// \name Output /// \name Output
/// @{ /// @{
@ -574,18 +571,101 @@ public:
/// \name Training /// \name Training
/// @{ /// @{
/*!
\brief Adds the item at position `index` as an inlier of
`class_type` for the training algorithm.
\note This inlier is only used for training. There is no guarantee
that the item at position `index` will be classified as `class_type`
after calling `run()`, `run_with_local_smoothing()` or
`run_with_graphcut()`.
\return `true` if the inlier was correctly added, `false`
otherwise (if `class_type` was not found).
*/
bool set_inlier (Type_handle class_type, std::size_t index)
{
std::size_t type_idx = (std::size_t)(-1);
for (std::size_t i = 0; i < m_types.size(); ++ i)
if (m_types[i] == class_type)
{
type_idx = i;
break;
}
if (type_idx == (std::size_t)(-1))
return false;
if (m_training_type.empty())
reset_inlier_sets();
m_training_type[index] = type_idx;
return true;
}
/*!
\brief Adds the items at positions `indices` as inliers of
`class_type` for the training algorithm.
\note These inliers are only used for training. There is no
guarantee that the items at positions `indices` will be classified
as `class_type` after calling `run()`,
`run_with_local_smoothing()` or `run_with_graphcut()`.
\tparam IndexRange range of `std::size_t`, model of `ConstRange`.
*/
template <class IndexRange>
bool set_inliers (Type_handle class_type,
IndexRange indices)
{
std::size_t type_idx = (std::size_t)(-1);
for (std::size_t i = 0; i < m_types.size(); ++ i)
if (m_types[i] == class_type)
{
type_idx = i;
break;
}
if (type_idx == (std::size_t)(-1))
return false;
if (m_training_type.empty())
reset_inlier_sets();
for (typename IndexRange::const_iterator it = indices.begin();
it != indices.end(); ++ it)
m_training_type[*it] = type_idx;
return true;
}
/*!
\brief Resets inlier sets used for training.
*/
void reset_inlier_sets()
{
std::vector<std::size_t>(m_input.size(), (std::size_t)(-1)).swap (m_training_type);
}
/*! /*!
\brief Runs the training algorithm. \brief Runs the training algorithm.
All the `Classification::Type` and `Classification::Attribute` All the `Classification::Type` and `Classification::Attribute`
necessary for the classification should have been added before necessary for classification should have been added before running
running this function. this function. Each classification type must have ben given a small set
of user-defined inliers to provide the training algorithm with a
ground truth (see `set_inlier()` and `set_inliers()`).
Each classification type must be given a small set of user-defined This methods estimates the set of attribute weights and of
inliers to provide the training algorithm with a ground truth. [effects](@ref Classification::Attribute::Effect) that make the
classifier succeed in correctly classifying the sets of inliers
given by the user. These parameters are directly modified within
the `Classification::Attribute_base` and `Classification::Type`
objects. After training, the user can call `run()`,
`run_with_local_smoothing()` or `run_with_graphcut()` to compute
the classification using the estimated parameters.
\param nb_tests number of tests to perform. Higher values may \param nb_tests number of tests to perform. Higher values may
provide the user with better results at the cost of higher provide the user with better results at the cost of a higher
computation time. Using a value of at least 10 times the number of computation time. Using a value of at least 10 times the number of
attributes is advised. attributes is advised.
@ -796,81 +876,6 @@ public:
} }
/*!
\brief Resets inlier sets used for training.
*/
void reset_inlier_sets()
{
std::vector<std::size_t>(m_input.size(), (std::size_t)(-1)).swap (m_training_type);
}
/*!
\brief Adds the item at position `idx` as an inlier of
`class_type` for the training algorithm.
\note This inlier is only used for training. There is no guarantee
that the item at position `idx` will be classified as `class_type`
after calling `run()`, `run_with_local_smoothing()` or
`run_with_graphcut()`.
\return `true` if the inlier was correctly added, `false`
otherwise (if `class_type` was not found).
*/
bool set_inlier (Type_handle class_type, std::size_t idx)
{
std::size_t type_idx = (std::size_t)(-1);
for (std::size_t i = 0; i < m_types.size(); ++ i)
if (m_types[i] == class_type)
{
type_idx = i;
break;
}
if (type_idx == (std::size_t)(-1))
return false;
if (m_training_type.empty())
reset_inlier_sets();
m_training_type[idx] = type_idx;
return true;
}
/*!
\brief Adds the items at positions `indices` as inliers of
`class_type` for the training algorithm.
\note These inliers are only used for training. There is no
guarantee that the items at positions `indices` will be classified
as `class_type` after calling `run()`,
`run_with_local_smoothing()` or `run_with_graphcut()`.
\tparam IndexRange range of `std::size_t`, model of `ConstRange`.
*/
template <class IndexRange>
bool set_inliers (Type_handle class_type,
IndexRange indices)
{
std::size_t type_idx = (std::size_t)(-1);
for (std::size_t i = 0; i < m_types.size(); ++ i)
if (m_types[i] == class_type)
{
type_idx = i;
break;
}
if (type_idx == (std::size_t)(-1))
return false;
if (m_training_type.empty())
reset_inlier_sets();
for (typename IndexRange::const_iterator it = indices.begin();
it != indices.end(); ++ it)
m_training_type[*it] = type_idx;
return true;
}
/// @} /// @}
@ -904,6 +909,8 @@ public:
protected: protected:
/// \cond SKIP_IN_MANUAL
double classification_value (const std::size_t& class_type, double classification_value (const std::size_t& class_type,
const std::size_t& pt_index) const const std::size_t& pt_index) const
{ {
@ -1057,6 +1064,7 @@ protected:
return false; return false;
} }
/// \endcond
}; };

View File

@ -58,73 +58,74 @@ namespace CGAL {
set of generic attributes. Attributes can be generated at multiple set of generic attributes. Attributes can be generated at multiple
scales to increase the reliability of the classification. scales to increase the reliability of the classification.
\tparam Kernel model of \cgal Kernel. \tparam Geom_traits model of \cgal Kernel.
\tparam Range range of items, model of `ConstRange`. Its iterator type \tparam PointRange model of `ConstRange`. Its iterator type is
is `RandomAccessIterator`. `RandomAccessIterator`.
\tparam PointMap model of `ReadablePropertyMap` whose key \tparam PointMap model of `ReadablePropertyMap` whose key
type is the value type of the iterator of `Range` and value type type is the value type of the iterator of `PointRange` and value type
is `Point_3<Kernel>`. is `Geom_traits::Point_3`.
\tparam DiagonalizeTraits model of `DiagonalizeTraits` used \tparam DiagonalizeTraits model of `DiagonalizeTraits` used
for matrix diagonalization. for matrix diagonalization.
*/ */
template <typename Kernel, template <typename Geom_traits,
typename Range, typename PointRange,
typename PointMap, typename PointMap,
typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> > typename DiagonalizeTraits = CGAL::Default_diagonalize_traits<double,3> >
class Point_set_classifier : public Classifier<Range, PointMap> class Point_set_classifier : public Classifier<PointRange, PointMap>
{ {
public: public:
typedef typename Kernel::Iso_cuboid_3 Iso_cuboid_3; typedef typename Geom_traits::Iso_cuboid_3 Iso_cuboid_3;
typedef Classifier<Range, PointMap> Base; /// \cond SKIP_IN_MANUAL
typedef typename Range::const_iterator Iterator; typedef Classifier<PointRange, PointMap> Base;
typedef typename PointRange::const_iterator Iterator;
using Base::m_input; using Base::m_input;
using Base::m_item_map; using Base::m_item_map;
/// \endcond
typedef Classification::Planimetric_grid typedef Classification::Planimetric_grid
<Kernel, Range, PointMap> Planimetric_grid; <Geom_traits, PointRange, PointMap> Planimetric_grid;
typedef Classification::Point_set_neighborhood typedef Classification::Point_set_neighborhood
<Kernel, Range, PointMap> Neighborhood; <Geom_traits, PointRange, PointMap> Neighborhood;
typedef Classification::Local_eigen_analysis typedef Classification::Local_eigen_analysis
<Kernel, Range, PointMap, DiagonalizeTraits> Local_eigen_analysis; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Local_eigen_analysis;
/// \cond SKIP_IN_MANUAL
typedef Classification::Attribute_handle Attribute_handle; typedef Classification::Attribute_handle Attribute_handle;
typedef Classification::Type Type; typedef Classification::Type Type;
typedef Classification::Type_handle Type_handle; typedef Classification::Type_handle Type_handle;
/// \cond SKIP_IN_MANUAL typedef typename Geom_traits::Point_3 Point;
typedef typename Kernel::Point_3 Point;
typedef Classification::Attribute::Anisotropy typedef Classification::Attribute::Anisotropy
<Kernel, Range, PointMap, DiagonalizeTraits> Anisotropy; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Anisotropy;
typedef Classification::Attribute::Distance_to_plane typedef Classification::Attribute::Distance_to_plane
<Kernel, Range, PointMap, DiagonalizeTraits> Distance_to_plane; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Distance_to_plane;
typedef Classification::Attribute::Eigentropy typedef Classification::Attribute::Eigentropy
<Kernel, Range, PointMap, DiagonalizeTraits> Eigentropy; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Eigentropy;
typedef Classification::Attribute::Elevation typedef Classification::Attribute::Elevation
<Kernel, Range, PointMap> Elevation; <Geom_traits, PointRange, PointMap> Elevation;
typedef Classification::Attribute::Linearity typedef Classification::Attribute::Linearity
<Kernel, Range, PointMap, DiagonalizeTraits> Linearity; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Linearity;
typedef Classification::Attribute::Omnivariance typedef Classification::Attribute::Omnivariance
<Kernel, Range, PointMap, DiagonalizeTraits> Omnivariance; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Omnivariance;
typedef Classification::Attribute::Planarity typedef Classification::Attribute::Planarity
<Kernel, Range, PointMap, DiagonalizeTraits> Planarity; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Planarity;
typedef Classification::Attribute::Sphericity typedef Classification::Attribute::Sphericity
<Kernel, Range, PointMap, DiagonalizeTraits> Sphericity; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Sphericity;
typedef Classification::Attribute::Sum_eigenvalues typedef Classification::Attribute::Sum_eigenvalues
<Kernel, Range, PointMap, DiagonalizeTraits> Sum_eigen; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Sum_eigen;
typedef Classification::Attribute::Surface_variation typedef Classification::Attribute::Surface_variation
<Kernel, Range, PointMap, DiagonalizeTraits> Surface_variation; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Surface_variation;
typedef Classification::Attribute::Vertical_dispersion typedef Classification::Attribute::Vertical_dispersion
<Kernel, Range, PointMap> Dispersion; <Geom_traits, PointRange, PointMap> Dispersion;
typedef Classification::Attribute::Verticality typedef Classification::Attribute::Verticality
<Kernel, Range, PointMap, DiagonalizeTraits> Verticality; <Geom_traits, PointRange, PointMap, DiagonalizeTraits> Verticality;
/// \endcond
typedef typename Classification::RGB_Color RGB_Color; typedef typename Classification::RGB_Color RGB_Color;
/// \endcond
private: private:
struct Scale struct Scale
@ -135,7 +136,7 @@ private:
double voxel_size; double voxel_size;
std::vector<Attribute_handle> attributes; std::vector<Attribute_handle> attributes;
Scale (const Range& input, PointMap point_map, Scale (const PointRange& input, PointMap point_map,
const Iso_cuboid_3& bbox, double voxel_size) const Iso_cuboid_3& bbox, double voxel_size)
: voxel_size (voxel_size) : voxel_size (voxel_size)
{ {
@ -199,7 +200,7 @@ public:
\param point_map property map to access the input points. \param point_map property map to access the input points.
*/ */
Point_set_classifier(const Range& input, PointMap point_map) : Base (input, point_map) Point_set_classifier(const PointRange& input, PointMap point_map) : Base (input, point_map)
{ {
m_bbox = CGAL::bounding_box m_bbox = CGAL::bounding_box
(boost::make_transform_iterator (m_input.begin(), CGAL::Property_map_to_unary_function<PointMap>(m_item_map)), (boost::make_transform_iterator (m_input.begin(), CGAL::Property_map_to_unary_function<PointMap>(m_item_map)),
@ -222,8 +223,8 @@ public:
/*! /*!
\brief Generate all possible attributes from an input range. \brief Generate all possible attributes from an input range.
The smallest scale is automatically estimated and the data The size of the smallest scale is automatically estimated and the
structures needed (`Neighborhood`, `Planimetric_grid` and data structures needed (`Neighborhood`, `Planimetric_grid` and
`Local_eigen_analysis`) are computed at `nb_scales` recursively `Local_eigen_analysis`) are computed at `nb_scales` recursively
larger scales. At each scale, the following attributes are larger scales. At each scale, the following attributes are
generated: generated:
@ -238,13 +239,13 @@ public:
- `CGAL::Classification::Attribute::Sphericity` - `CGAL::Classification::Attribute::Sphericity`
- `CGAL::Classification::Attribute::Sum_eigenvalues` - `CGAL::Classification::Attribute::Sum_eigenvalues`
- `CGAL::Classification::Attribute::Surface_variation` - `CGAL::Classification::Attribute::Surface_variation`
- `CGAL::Classification::Attribute::Vertical_dispersion` - `CGAL::Classification::Attribute::Vertical_dispersion` based on eigenvalues
If normal vectors are provided (if `VectorMap` is different from If normal vectors are provided (if `VectorMap` is different from
`CGAL::Default`), the following attribute is generated at each `CGAL::Default`), the following attribute is generated at each
scale: scale:
- `CGAL::Classification::Attribute::Vertical_dispersion` - `CGAL::Classification::Attribute::Vertical_dispersion` based on normal vectors
If colors are provided (if `ColorMap` is different from If colors are provided (if `ColorMap` is different from
`CGAL::Default`), the following attributes are generated at each `CGAL::Default`), the following attributes are generated at each
@ -268,9 +269,15 @@ public:
- `CGAL::Classification::Attribute::Echo_scatter` - `CGAL::Classification::Attribute::Echo_scatter`
\tparam VectorMap model of `ReadablePropertyMap` with value type `Vector_3<Kernel>`. \tparam VectorMap model of `ReadablePropertyMap` whose key type is
\tparam ColorMap model of `ReadablePropertyMap` with value type `CGAL::Classification::RGB_Color`. the value type of the iterator of `PointRange` and value type is
\tparam EchoMap model of `ReadablePropertyMap` with value type `std::size_t`. `Geom_traits::Vector_3`.
\tparam ColorMap model of `ReadablePropertyMap` whose key type is
the value type of the iterator of `PointRange` and value type is
`CGAL::Classification::RGB_Color`.
\tparam EchoMap model of `ReadablePropertyMap` whose key type is
the value type of the iterator of `PointRange` and value type is
`std::size_t`.
\param nb_scales number of scales to compute. \param nb_scales number of scales to compute.
\param normal_map property map to access the normal vectors of the input points (if any). \param normal_map property map to access the normal vectors of the input points (if any).
\param color_map property map to access the colors of the input points (if any). \param color_map property map to access the colors of the input points (if any).
@ -284,7 +291,7 @@ public:
ColorMap color_map = ColorMap(), ColorMap color_map = ColorMap(),
EchoMap echo_map = EchoMap()) EchoMap echo_map = EchoMap())
{ {
typedef typename Default::Get<VectorMap, typename Kernel::Vector_3 >::type typedef typename Default::Get<VectorMap, typename Geom_traits::Vector_3 >::type
Vmap; Vmap;
typedef typename Default::Get<ColorMap, RGB_Color >::type typedef typename Default::Get<ColorMap, RGB_Color >::type
Cmap; Cmap;
@ -328,21 +335,34 @@ public:
*/ */
const Local_eigen_analysis& eigen(std::size_t scale = 0) const { return *(m_scales[scale]->eigen); } const Local_eigen_analysis& eigen(std::size_t scale = 0) const { return *(m_scales[scale]->eigen); }
/*! /*!
\brief Returns the grid resolution at scale `scale`. \brief Returns the number of scales that were computed.
*/
std::size_t number_of_scales() const { return m_scales.size(); }
/*!
\brief Returns the grid resolution at scale `scale`. This
resolution is the length and width of a cell of the
`Planimetric_grid` defined at this scale.
\note `generate_attributes()` must have been called before calling \note `generate_attributes()` must have been called before calling
this method. this method.
*/ */
double grid_resolution(std::size_t scale = 0) const { return m_scales[scale]->grid_resolution(); } double grid_resolution(std::size_t scale = 0) const { return m_scales[scale]->grid_resolution(); }
/*! /*!
\brief Returns the radius used for neighborhood queries at scale `scale`.
\brief Returns the radius used for neighborhood queries at scale
`scale`. This radius is the smallest radius that is relevant from
a geometric point of view at this scale (that is to say that
encloses a few cells of `Planimetric_grid`).
\note `generate_attributes()` must have been called before calling \note `generate_attributes()` must have been called before calling
this method. this method.
*/ */
double radius_neighbors(std::size_t scale = 0) const { return m_scales[scale]->radius_neighbors(); } double radius_neighbors(std::size_t scale = 0) const { return m_scales[scale]->radius_neighbors(); }
/*! /*!
\brief Returns the radius used for digital terrain modeling at scale `scale`. \brief Returns the radius used for digital terrain modeling at
scale `scale`. This radius represents the minimum size of a
building at this scale.
\note `generate_attributes()` must have been called before calling \note `generate_attributes()` must have been called before calling
this method. this method.
@ -421,7 +441,7 @@ public:
std::cerr << "Normal based attributes computed in " << t.time() << " second(s)" << std::endl; std::cerr << "Normal based attributes computed in " << t.time() << " second(s)" << std::endl;
} }
void generate_normal_based_attributes(const CGAL::Default_property_map<Iterator, typename Kernel::Vector_3>&) void generate_normal_based_attributes(const CGAL::Default_property_map<Iterator, typename Geom_traits::Vector_3>&)
{ {
CGAL::Timer t; t.start(); CGAL::Timer t; t.start();
generate_multiscale_attribute_variant_0<Verticality> (); generate_multiscale_attribute_variant_0<Verticality> ();
@ -431,7 +451,7 @@ public:
void generate_color_based_attributes(ColorMap color_map) void generate_color_based_attributes(ColorMap color_map)
{ {
typedef Classification::Attribute::Hsv<Kernel, Range, ColorMap> Hsv; typedef Classification::Attribute::Hsv<Geom_traits, PointRange, ColorMap> Hsv;
CGAL::Timer t; t.start(); CGAL::Timer t; t.start();
for (std::size_t i = 0; i <= 8; ++ i) for (std::size_t i = 0; i <= 8; ++ i)
{ {
@ -459,7 +479,7 @@ public:
template <typename EchoMap> template <typename EchoMap>
void generate_echo_based_attributes(EchoMap echo_map) void generate_echo_based_attributes(EchoMap echo_map)
{ {
typedef Classification::Attribute::Echo_scatter<Kernel, Range, PointMap, EchoMap> Echo_scatter; typedef Classification::Attribute::Echo_scatter<Geom_traits, PointRange, PointMap, EchoMap> Echo_scatter;
CGAL::Timer t; t.start(); CGAL::Timer t; t.start();
for (std::size_t i = 0; i < m_scales.size(); ++ i) for (std::size_t i = 0; i < m_scales.size(); ++ i)
{ {
@ -510,9 +530,9 @@ public:
This allows to easily save and recover a specific classification This allows to easily save and recover a specific classification
configuration, that is to say: configuration, that is to say:
- The computed scales - The size of the smallest scale
- The attributes and their respective weights - The attributes and their respective weights
- The classification types and the effect the attributes have on them - The classification types and the effects of the attributes on them
The output file is written in an XML format that is readable by The output file is written in an XML format that is readable by
the `load_configuration()` method. the `load_configuration()` method.
@ -582,9 +602,15 @@ public:
The input file should be in the XML format written by the The input file should be in the XML format written by the
`save_configuration()` method. `save_configuration()` method.
\tparam VectorMap model of `ReadablePropertyMap` with value type `Vector_3<Kernel>`. \tparam VectorMap model of `ReadablePropertyMap` whose key type is
\tparam ColorMap model of `ReadablePropertyMap` with value type `CGAL::Classification::RGB_Color`. the value type of the iterator of `PointRange` and value type is
\tparam EchoMap model of `ReadablePropertyMap` with value type `std::size_t`. `Geom_traits::Vector_3`.
\tparam ColorMap model of `ReadablePropertyMap` whose key type is
the value type of the iterator of `PointRange` and value type is
`CGAL::Classification::RGB_Color`.
\tparam EchoMap model of `ReadablePropertyMap` whose key type is
the value type of the iterator of `PointRange` and value type is
`std::size_t`.
\param input input stream. \param input input stream.
\param normal_map property map to access the normal vectors of the input points (if any). \param normal_map property map to access the normal vectors of the input points (if any).
\param color_map property map to access the colors of the input points (if any). \param color_map property map to access the colors of the input points (if any).
@ -598,7 +624,7 @@ public:
ColorMap color_map = ColorMap(), ColorMap color_map = ColorMap(),
EchoMap echo_map = EchoMap()) EchoMap echo_map = EchoMap())
{ {
typedef typename Default::Get<VectorMap, typename Kernel::Vector_3 >::type typedef typename Default::Get<VectorMap, typename Geom_traits::Vector_3 >::type
Vmap; Vmap;
typedef typename Default::Get<ColorMap, RGB_Color >::type typedef typename Default::Get<ColorMap, RGB_Color >::type
Cmap; Cmap;
@ -615,11 +641,11 @@ public:
/*! /*!
\brief Writes a classification in a colored and labeled PLY format \brief Writes the classified point set in a colored and labeled
in the stream `output`. PLY format in the stream `output`.
The input point set is written in a PLY format with the addition The input points are written in a PLY format with the addition of
of several PLY properties: the following PLY properties:
- a property `label` that indicates which classification type is - a property `label` that indicates which classification type is
assigned to the point. The types are indexed from 0 to N (the assigned to the point. The types are indexed from 0 to N (the
@ -773,8 +799,8 @@ private:
ColorMap color_map, ColorMap color_map,
EchoMap echo_map) EchoMap echo_map)
{ {
typedef Classification::Attribute::Echo_scatter<Kernel, Range, PointMap, EchoMap> Echo_scatter; typedef Classification::Attribute::Echo_scatter<Geom_traits, PointRange, PointMap, EchoMap> Echo_scatter;
typedef Classification::Attribute::Hsv<Kernel, Range, ColorMap> Hsv; typedef Classification::Attribute::Hsv<Geom_traits, PointRange, ColorMap> Hsv;
clear(); clear();
@ -842,7 +868,7 @@ private:
else if (id == "verticality") else if (id == "verticality")
{ {
if (boost::is_convertible<VectorMap, if (boost::is_convertible<VectorMap,
typename CGAL::Default_property_map<Iterator, typename Kernel::Vector_3> >::value) typename CGAL::Default_property_map<Iterator, typename Geom_traits::Vector_3> >::value)
this->template add_attribute<Verticality>(*(m_scales[scale]->eigen)); this->template add_attribute<Verticality>(*(m_scales[scale]->eigen));
else else
this->template add_attribute<Verticality>(normal_map); this->template add_attribute<Verticality>(normal_map);