<p>Yes and no. The RGB values are most likely gamma compressed.</p>

<p>Consider gamma calibration images like the one below.</p>

<p>For a well calibrated monitor the gray value should look the same as the pattern of black and white lines.</p>

<p>If you load in the image you will likely find RGB values of $186$. </p>

<p>$(186/255)^{2.2} \approx 0.5$, which means that a halftone pattern of black and white lines of equal width correspond to RGB values of 186.</p>

<p><a href="https://i.sstatic.net/HLZNI.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HLZNI.gif" alt="gamma calibration image"></a></p>

<hr>

<p>However, the gamma compression applied was more likely the sRGB gamma compression than an overall gamma of $2.2$.</p>

<p>$$
\frac{w_\text{white}}{w_\text{white}+w_\text{black}} =
\begin{cases}
12.92V  &amp;\text{ if } V \leq 0.0031308 \\
1.055 V^{1/2.4} + 0.055 &amp;\text{ if } V &gt; 0.0031308 
\end{cases}
$$</p>

<p>where $V = 0.299R+0.587G+0.114B$</p>

CC BY-SA 3.0
2018-01-26T14:50:06.340Z
"The RGB values are most likely gamma compressed." That's common for 8-bit images, but you need to actually *know*, not just guess. Monitor calibration is a bit of a red herring nowadays, because applications should be drawing sRGB and the monitor should be interpreting its input as sRGB anyway.
Dan Hulme
CC BY-SA 3.0
2018-01-26T20:32:44.903Z
A typical display is calibrated to sRGB, not gamma 2.2.  So you should use the linear to sRGB or sRGB to linear conversions.  And a 50% sRGB value should be 188, not 186.  (see Wikipedia article for sRGB which says that a normalized 50% intensity should get an sRGB value of (1.055*0.5^(1/2.4))-0.055 = 0.735358, which is about 187.516 in 8-bit sRGB, hence the logic of encoding it as 188.
Wyck
CC BY-SA 3.0
2018-01-27T16:01:51.310Z
The monitor calibration image is indeed kind of misleading for my argument. It does show that I should perform gamma expansion, but not which one.
Am I correct to conclude that most images will likely be encoded with sRGB and I should use the formula provided by @Wyck? ($1.055L^{1/2.4}-0.055$)
Tim Kuipers
CC BY-SA 3.0
2018-02-27T08:46:41.673Z
Given that you are only doing half-toning, you could probably get away with a *much* cheaper approximation of gamma/sRGB such as using a square root.
Simon F
CC BY-SA 3.0
2018-02-28T11:08:03.270Z
@Wyck a typical display is non calibrated.
joojaa
CC BY-SA 3.0
2018-01-26T14:32:31.200Z
2018-01-27T16:40:15.027Z
2018-01-27T16:40:15.027Z
Tim Kuipers
<p>I'm writing a halftone algorithm, which takes standards RGB intensities in the range of $0-255$ and outputs black and white elements with a corresponding size ratio.</p>

<p>Should I apply a gamma expansion on the input luminance to get the ratio?</p>

<p>I.e. is it correct to do the following?</p>

<p>$\frac{w_\text{white}}{w_\text{white}+w_\text{black}} = (0.299 R + 0.587 G + 0.114 B)^{2.2}$</p>

<p>Should I apply the exponent of $2.2$?</p>

<gamma>
Gamma correction and halftone
Tim Kuipers
# Gamma correction and halftone

(Asked by: username_0 on 2018-01-26)

I'm writing a halftone algorithm, which takes standards RGB intensities in the range of $0-255$ and outputs black and white elements with a corresponding size ratio.

Should I apply a gamma expansion on the input luminance to get the ratio?

I.e. is it correct to do the following?

$\frac{w\_\text{white}}{w\_\text{white}+w\_\text{black}} = (0.299 R + 0.587 G + 0.114 B)^{2.2}$

Should I apply the exponent of $2.2$?

**Tags:** gamma


---

## 1 answers

### Answer by username_0 on 2018-01-26. Score: 1

Yes and no. The RGB values are most likely gamma compressed.

Consider gamma calibration images like the one below.

For a well calibrated monitor the gray value should look the same as the pattern of black and white lines.

If you load in the image you will likely find RGB values of $186$.

$(186/255)^{2.2} \approx 0.5$, which means that a halftone pattern of black and white lines of equal width correspond to RGB values of 186.

[![gamma calibration image](https://i.sstatic.net/HLZNI.gif)](https://i.sstatic.net/HLZNI.gif)

---

However, the gamma compression applied was more likely the sRGB gamma compression than an overall gamma of $2.2$.

$$
\frac{w\_\text{white}}{w\_\text{white}+w\_\text{black}} =
\begin{cases}
12.92V &\text{ if } V \leq 0.0031308 \\
1.055 V^{1/2.4} + 0.055 &\text{ if } V > 0.0031308
\end{cases}
$$

where $V = 0.299R+0.587G+0.114B$

> **Comments:**
> **username_1**: "The RGB values are most likely gamma compressed." That's common for 8-bit images, but you need to actually *know*, not just guess. Monitor calibration is a bit of a red herring nowadays, because applications should be drawing sRGB and the monitor should be interpreting its input as sRGB anyway.  
> **username_2**: A typical display is calibrated to sRGB, not gamma 2.2.  So you should use the linear to sRGB or sRGB to linear conversions.  And a 50% sRGB value should be 188, not 186.  (see Wikipedia article for sRGB which says that a normalized 50% intensity should get an sRGB value of (1.055*0.5^(1/2.4))-0.055 = 0.735358, which is about 187.516 in 8-bit sRGB, hence the logic of encoding it as 188.  
> **username_0**: The monitor calibration image is indeed kind of misleading for my argument. It does show that I should perform gamma expansion, but not which one. Am I correct to conclude that most images will likely be encoded with sRGB and I should use the formula provided by @username_2? ($1.055L^{1/2.4}-0.055$)  
> **username_3**: Given that you are only doing half-toning, you could probably get away with a *much* cheaper approximation of gamma/sRGB such as using a square root.  
> **username_4**: @username_2 a typical display is non calibrated.  

---

