import numpy
# RGB in 0..1; YCbCr in 8-bit space
RGB_to_YCbCr = numpy.array([
[ 65.481, 128.553, 24.966, 16],
[ -37.797, -74.203, 112.000, 128],
[ 112.000, -93.786, -18.214, 128],
[ 0, 0, 0, 1],
])
# white, yellow, cyan, green, magenta, red, blue, black
Rs = [255, 255, 0, 0, 255, 255, 0, 0]
Gs = [255, 255, 255, 255, 0, 0, 0, 0]
Bs = [255, 0, 255, 0, 255, 0, 255, 0]
for R, G, B in zip(Rs, Gs, Bs):
Y, Cb, Cr, _ = RGB_to_YCbCr @ [R / 255, G / 255, B / 255, 1]
print(f"{int(round(Y)):>3} {int(round(Cb - 128)):>4} {int(round(Cr - 128)):>4}")
aW1wb3J0IG51bXB5CgojIFJHQiBpbiAwLi4xOyBZQ2JDciBpbiA4LWJpdCBzcGFjZQpSR0JfdG9fWUNiQ3IgPSBudW1weS5hcnJheShbCiAgICBbICA2NS40ODEsIDEyOC41NTMsICAyNC45NjYsICAxNl0sCiAgICBbIC0zNy43OTcsIC03NC4yMDMsIDExMi4wMDAsIDEyOF0sCiAgICBbIDExMi4wMDAsIC05My43ODYsIC0xOC4yMTQsIDEyOF0sCiAgICBbICAgICAgIDAsICAgICAgIDAsICAgICAgIDAsICAgIDFdLApdKQoKIyB3aGl0ZSwgeWVsbG93LCBjeWFuLCBncmVlbiwgbWFnZW50YSwgcmVkLCBibHVlLCBibGFjawpScyA9IFsyNTUsIDI1NSwgICAwLCAgIDAsIDI1NSwgMjU1LCAgIDAsIDBdCkdzID0gWzI1NSwgMjU1LCAyNTUsIDI1NSwgICAwLCAgIDAsICAgMCwgMF0KQnMgPSBbMjU1LCAgIDAsIDI1NSwgICAwLCAyNTUsICAgMCwgMjU1LCAwXQoKZm9yIFIsIEcsIEIgaW4gemlwKFJzLCBHcywgQnMpOgogICAgWSwgQ2IsIENyLCBfID0gUkdCX3RvX1lDYkNyIEAgW1IgLyAyNTUsIEcgLyAyNTUsIEIgLyAyNTUsIDFdCiAgICBwcmludChmIntpbnQocm91bmQoWSkpOj4zfSB7aW50KHJvdW5kKENiIC0gMTI4KSk6PjR9IHtpbnQocm91bmQoQ3IgLSAxMjgpKTo+NH0iKQ==