CGAL 6.0 - Classification
Loading...
Searching...
No Matches
CGAL::Classification::Label_set Class Reference

#include <CGAL/Classification/Label_set.h>

Definition

sets of Label used as input by classification algorithms.

Public Types

using const_iterator = unspecified_type
 A random access constant iterator with value type Label_handle.
 
using iterator = unspecified_type
 A random access iterator with value type Label_handle.
 

Constructors

 Label_set ()
 
 Label_set (std::initializer_list< const char * > labels)
 constructs a label set from a set of label names.
 

Modifications

Label_handle add (const char *name, CGAL::IO::Color color, std::size_t standard_index=-1)
 adds a label.
 
Label_handle add (const char *name)
 adds a label with default standard index and color.
 
bool remove (Label_handle label)
 removes a label.
 
void clear ()
 removes all labels.
 

Access

const_iterator begin () const
 
iterator begin ()
 
const_iterator end () const
 
iterator end ()
 
std::size_t size () const
 returns how many labels are defined.
 
Label_handle operator[] (std::size_t i) const
 returns the \(i^{th}\) label.
 

Validity

template<typename LabelIndexRange >
bool is_valid_ground_truth (const LabelIndexRange &ground_truth, bool verbose=false) const
 checks the validity of the ground truth with respect to the label set.
 

Member Function Documentation

◆ add() [1/2]

Label_handle CGAL::Classification::Label_set::add ( const char *  name)

adds a label with default standard index and color.

This functions tries to map label names to standard ASPRS labels and automatically picks the standard_index and color of the label:

  • "unassigned" is given standard index 2 and color (0, 0, 0)
  • "ground" is given standard index 2 and color (186, 189, 182)
  • "low_vegetation" is given standard index 3 and color (78, 154, 6)
  • "medium_vegetation" is given standard index 4 and color (138, 226, 52)
  • "high_vegetation" is given standard index 5 and color (204, 255, 201)
  • "building" is given standard index 6 and color (245, 121, 0)
  • "noise" is given standard index 7 and color (128, 0, 0)
  • "reserved" is given standard index 8 and color (233, 185, 110)
  • "water" is given standard index 9 and color (114, 159, 207)
  • "rail" is given standard index 10 and color (136, 46, 25)
  • "road_surface" is given standard index 11 and color (56, 56, 56)
  • "reserved_2" is given standard index 12 and color (193, 138, 51)
  • "wire_guard" is given standard index 13 and color (37, 61, 136)
  • "wire_conductor" is given standard index 14 and color (173, 127, 168)
  • "transmission_tower" is given standard index 15 and color (136, 138, 133)
  • "wire_connect" is given standard index 16 and color (145, 64, 236)
  • "bridge_deck" is given standard index 17 and color (213, 93, 93)
  • "high_noise" is given standard index 18 and color (255, 0, 0)

If the name is not found, the label is given standard index std::size_t(-1) and a random color.

Note
Names are not used for identification: two labels in the same set can have the same name but not the same handle. Each call to add() generates a new distinct label.
Parameters
namename of the label.
Returns
a handle to the newly added label.

◆ add() [2/2]

Label_handle CGAL::Classification::Label_set::add ( const char *  name,
CGAL::IO::Color  color,
std::size_t  standard_index = -1 
)

adds a label.

Note
Names, standard indices and colors are not used for identification: two labels in the same set can have the same name, standard index or color, but not the same handle. Each call to add() generates a new distinct label.
Parameters
namename of the label.
colorused to represent the label.
standard_indexstandard index of the classification label (i.e. index in the ASPRS standard).
Returns
a handle to the newly added label.

◆ is_valid_ground_truth()

template<typename LabelIndexRange >
bool CGAL::Classification::Label_set::is_valid_ground_truth ( const LabelIndexRange &  ground_truth,
bool  verbose = false 
) const

checks the validity of the ground truth with respect to the label set.

Parameters
ground_truthrange of label indices. This function checks that all these indices are either -1 (for unclassified) or a valid index of one of the labels. If at least one of the indices is out of range, this function returns false, otherwise it returns true.
verboseif set to true, the number of inliers of each label, the number of unclassified items and the potential number of out-of-range items are displayed. Otherwise, this function does not display anything.

◆ remove()

bool CGAL::Classification::Label_set::remove ( Label_handle  label)

removes a label.

Parameters
labelthe handle to the label that must be removed.
Returns
true if the label was correctly removed, false if its handle was not found.