Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

stough 202-

Preview: Showing interesting intensity transforms on an image.

Pretty much exactly from DIP 3-3.2 from Gonzalez/Woods.

Showing interesting transfer functions on a gray image of a flower. This is a compact companion to the transfer functions notebook: one image, five transfer functions s=T(r)s = \mathbf{T}(r), and their curves shown right above their results, so you can connect the shape of each curve to what it does to the image.

<Figure size 500x400 with 1 Axes>

The image is rescaled to span the full range [0,255][0,255], and converted to grayscale if it was stored in color (with the usual luminance weights, much like the YY in YCbCr).

<Figure size 1000x200 with 5 Axes>
<Figure size 1000x200 with 5 Axes>

Read each curve as “input intensity on the x-axis, output intensity on the y-axis”. Where a curve is steep, a small range of input intensities gets spread over a large range of outputs: contrast increases there. Where it’s flat, inputs get squeezed together and contrast is lost.

  • linear: the identity, s=rs=r. Nothing changes.

  • log, s∝log⁡(1+r)s \propto \log(1+r): very steep for dark values and flat for bright ones. The shadows of the flower open up dramatically, but the bright petals compress together and wash out.

  • sqrt, s∝r1/2s \propto r^{1/2}: the same idea, more gently. It’s a gamma of γ=0.5\gamma = 0.5.

  • square, s∝r2s \propto r^{2}: the opposite, γ=2\gamma = 2. It’s flat in the darks and steep in the brights. Most of the image sinks into black, but differences among the brightest petals are exaggerated.

  • inv, s=255−rs = 255 - r: the photographic negative. It has a constant slope (just negative), so it doesn’t change contrast at all, only which end is light. Even so, details can be easier to see on a light background than a dark one.

Notice that each transformed image is rescaled for display afterward, so we’re comparing the shapes of the transforms, not their absolute brightness.