MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TextColorString

Method TextColorString

tensorflow/lite/toco/dump_graphviz.cc:88–93  ·  view source on GitHub ↗

The color to use for this node; will be used as 'fillcolor' for its box. See Color::AsHexString. A suitable, different color will be chosen for the 'fontcolor' for the inside text label, see Color::TextColorString. Returns the serialization in graphviz format of a suitable color to use 'fontcolor' in the same boxes. It should black or white, whichever offers the better contrast from AsHexString().

Source from the content-addressed store, hash-verified

86 // 'fontcolor' in the same boxes. It should black or white, whichever offers
87 // the better contrast from AsHexString().
88 string TextColorString() const {
89 // https://en.wikipedia.org/wiki/Relative_luminance
90 const float luminance = 0.2126f * r_ + 0.7152f * g_ + 0.0722f * b_;
91 const uint8 l = luminance > 128.f ? 0 : 255;
92 return StringF("#%.2X%.2X%.2X", l, l, l);
93 }
94
95 private:
96 uint8 r_ = 0, g_ = 0, b_ = 0;

Callers 2

DumpOperatorFunction · 0.80
DumpArrayFunction · 0.80

Calls 1

StringFFunction · 0.85

Tested by

no test coverage detected