29 template <
class Scalar,
class Label>
33 namespace LabelToColorMaps {
46 template <
class Scalar,
class Label>
48 auto const convertedLabel =
static_cast<std::uint64_t
>(label);
51 if ((convertedLabel & 0xffffffffff000000) != 0) {
52 throw std::invalid_argument(
"Given label cannot losslessly be converted to " 53 "24-bit unsigned integer");
56 auto const redScaled = convertedLabel & 0xff;
57 auto const greenScaled = (convertedLabel & 0xff00) >> 8;
58 auto const blueScaled = (convertedLabel & 0xff0000) >> 16;
60 auto const red =
static_cast<Scalar
>(redScaled) / Scalar{255};
61 auto const green =
static_cast<Scalar
>(greenScaled) / Scalar{255};
62 auto const blue =
static_cast<Scalar
>(blueScaled) / Scalar{255};
64 return std::array<Scalar, 3>{{red, green, blue}};
Name namespace for CortidQCT library.
Definition: CortidQCT.h:23
std::function< std::array< Scalar, 3 >(Label)> LabelToColorMap
Label to color map.
Definition: LabelToColorMap.h:30
std::array< Scalar, 3 > defaultMap(Label label)
Default label to color map.
Definition: LabelToColorMap.h:47