Skip to main content
← Lab

grayu8

confirmedupstream bugPython · kornia / PyTorchSystems & data structuresJuly 25, 2026

the question

Does kornia's rgb_to_grayscale uint8 path compute correct luminance without overflow?

what came out

kornia's rgb_to_grayscale uint8 branch multiplies channels by fixed-point weights [76,150,29] in uint8 with no >>8, wrapping mod 256. White (255,255,255) becomes 1, mid-gray 100 becomes 156, and red becomes 180 versus luma 76. The float path returns the correct luminance.

method & receipts

  • Result: confirmed
  • Reproducible one script re-runs the whole thing from scratch.
  • Tested — a correctness/benchmark suite ships alongside the code.

→ read the code and re-run it

github.com/v-code01/grayu8