Return to Computer Vision Notebooks

Grayscale Conversion



Color image conversion methods from RGB to grayscale.

0. Input RGB image


1. Arithmetic mean


$$ \large \varsigma = \frac{\sum_{i}^{n} C_i}{n} = \frac{R+G+B}{3} $$

2. Geometric mean


$$ \large \varsigma = \left(\prod_{i}^{n}C_i\right)^\frac{1}{n}=(R \cdot G \cdot B)^\frac{1}{3} $$

3. Harmonic mean


$$ \large \varsigma = \frac{n}{\sum_{i}^{n}\frac{1}{C_i}}=\frac{3}{\frac{1}{R}+\frac{1}{G}+\frac{1}{B}} $$

4.1 Minimum value


$$ \large \varsigma = RGB_{\text{min}} $$

4.2 Maximum value


$$ \large \varsigma = RGB_{\text{max}} $$

5. Lightness


$$ \large \varsigma = \frac{RGB_{\text{max}} + RGB_{\text{min}}}{2} $$

6. Median value


$$ \large \varsigma = RGB_{\text{median}} $$

7. Luminosity


$$ \large \varsigma = 0.2126 R + 0.7152 G + 0.0722 B $$