CortidQCT  1.2.2.52
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CortidQCT::ColorToLabelMaps::CustomMap Struct Reference

A customaizable color to label map. More...

#include <ColorToLabelMap.h>

Public Types

using LabelType = std::uint64_t
 
using Table = std::unordered_map< ColorRGB, LabelType >
 

Public Member Functions

template<class Scalar , class Label >
 operator ColorToLabelMap< Label, Scalar > () const
 Return a ColorToLabelMap representing the current map.
 
template<class Label , class Scalar >
Label operator() (Scalar red, Scalar green, Scalar blue) const
 Converts a RGB color to a label using the pre-defined lookup table. More...
 
CustomMaploadFromFile (std::string const &filename)
 Loads the custom map from a YAML file. More...
 

Static Public Member Functions

static CustomMap fromFile (std::string const &filename)
 Convenience initializer to load custom map from file. More...
 

Public Attributes

Table table
 mapping table More...
 
LabelType undefinedLabel {0}
 

Detailed Description

A customaizable color to label map.

Member Function Documentation

static CustomMap CortidQCT::ColorToLabelMaps::CustomMap::fromFile ( std::string const &  filename)
inlinestatic

Convenience initializer to load custom map from file.

See also
loadFromFile
CustomMap & CortidQCT::ColorToLabelMaps::CustomMap::loadFromFile ( std::string const &  filename)

Loads the custom map from a YAML file.

Parameters
filenamePath to the yaml file
Returns
Reference to the loaded map
Exceptions
std::invalid_argumentif loading fails
template<class Label , class Scalar >
Label CortidQCT::ColorToLabelMaps::CustomMap::operator() ( Scalar  red,
Scalar  green,
Scalar  blue 
) const
inline

Converts a RGB color to a label using the pre-defined lookup table.

Template Parameters
Scalarscalar type of the color components (floating point)
Labellabel type, must be constructible from std::unit64_t
Parameters
redred compnent in range [0, 1]
greengreen component in range [0, 1]
blueblue component in range [0, 1]
Returns
Label value from the lookup table. If no matching entry can be found in the table, undefinedLabel is returned.

Member Data Documentation

Table CortidQCT::ColorToLabelMaps::CustomMap::table
Initial value:
= {{{{255, 0, 0}}, 0}, {{{0, 255, 0}}, 1},
{{{255, 255, 0}}, 2}, {{{0, 0, 255}}, 3},
{{{255, 0, 255}}, 4}, {{{0, 255, 255}}, 5}}

mapping table

Maps RGB colors to labels. Defautl value maps the colors red, green, yellow, green, magenta, cyan to 0, 1, 2, 3, 4, 5, respectively.

LabelType CortidQCT::ColorToLabelMaps::CustomMap::undefinedLabel {0}

The label that is returned when no matching entry in the table can be found


The documentation for this struct was generated from the following files: