Lulumoy Studio

Math guide

Change format

Images are stored with 8 bits (0–255) or 16 bits (0–65535) per channel, as grayscale (1 channel) or colour (3 channels, plus optional alpha).

v16=257·v8,v8=round(v16257)
257 = 65535/255, so 255 maps exactly to 65535 and a round trip loses nothing. Going from 16 to 8 bits does lose precision.
Y=0.299R+0.587G+0.114B
Luminance (ITU-R BT.601) when converting to grayscale; the alpha channel is dropped.
R=G=B=Y
From grayscale to colour, the three channels take the same value (the look does not change, but colour operations become possible).

References

  1. OpenCV 4.x documentation — Color conversions (RGB ↔ GRAY). docs.opencv.org/4.x/de/d25/imgproc_color_conversions.html
  2. ITU-R Recommendation BT.601: Studio encoding parameters of digital television. www.itu.int/rec/R-REC-BT.601