Boolean operations can be performed on images:
union( a, b ) = max(a,b)
complement( a ) = (max pixel value) - a
difference( a, b ) = |a - b|
(What is the difference operation called for binary data?)
Below, the left image is complemented to get the middle image. The right image is the union of the left image and constant mid-level image (not shown).
[Gonzales and Woods figure 2.32]
The original pixel value, $x$, is transformed to a new pixel value, $x'$: $$x' = T(x)$$
Assume that $x$ and $x'$ are in range $[0,1]$.
Look at the graph of $T(x)$ to understand what's happening:
For a linear transformation, $T(x) = a x + b$.
$a$ controls the contrast (a larger $a$ yields more contrast stretch)
$b$ controls the brightness
[See demo of chest x-ray]
For a power transformation, $T(x) = x^\gamma, \; \gamma > 0$.
for $\gamma>1$: dark pixels get compressed; bright pixels get stretched
for $\gamma=1$: no change
for $\gamma<1$: dark pixels get stretched; bright pixels get compressed
[Gonzales and Woods]
[See demo of flower with changing $\gamma$]
"Gamma correction" is a power transformation to make image appear correct on an output device:
[Gonzales and Woods]