[Math] intensity transformation 16-bit image to a 8-bit image

image processing

Give an intensity transformation function T for converting a 16-bit image to a 8-bit image, i.e. T takes an integer from {0,1,2,…,65535} and returns an integer from {0,1,2,…,255}.

Can we use $s = T(r) = \left \lfloor \sqrt{r}\right \rfloor$?

Best Answer

You can certainly use whatever you'd like. However, this won't produce an even-looking image. Why? Look at a table of what input maps to what output: $$\begin{array}{|c|c|}\hline \text{Input} & \text{Output} \\ \hline 1 & 1 \\ \hline \vdots & \vdots \\ \hline 4 & 2 \\ \hline \vdots & \vdots \\ \hline 9 & 3 \\ \hline \vdots & \vdots \\ \hline 16 & 4 \\ \hline \vdots & \vdots \\ \hline 25 & 5 \\\hline \end{array}$$

Ok. So that was interesting and trivial. What does this mean? Notice that the input maps $3$ digits to $1$, $5$ digits to $2$, $7$ digits to $3$, etc. This indicates that the image will be more weighted in the lighter/higher colors.

Another way to look at this is to say that the ideal image transformation would have the midpoint be the same on both. That is, if you plug $\frac{2^{16}}{2}$ into the transformation, you'd get back $\frac{2^8}{2}$. The same goes for all other denominators: $\frac{2^{16}}{4} \to \frac{2^8}{4}$, etc.

You may want to look at using the $\log_2(x)$ function... (not sure how this would pan out, but it could work).

Related Question