Computer Vision Lab Algorithms Linear (min-max) normalisation

Linear (min-max) normalisation

Min-max normalization

Rescaling the values to a fixed range such as 0–255 or 0–1.

In the browserImage processingPoint processing

This content was prepared automatically from documented sources and its human scientific review is not yet complete. If you find an error, let us know.

Mathematical formula

x' = \frac{x - \min(x)}{\max(x) - \min(x)}\,(b - a) + a

Explanation

It stretches the actual intensity range over the whole available range. In neural networks it is often followed by normalisation with the mean and standard deviation of the training set (such as the ImageNet mean).

Detailed explanation

Intuition

Images differ in their actual range: a medical image may have values between 0 and 4095, and a dull image between 80 and 160. Linear normalisation maps the actual range onto a fixed range, so the images become comparable and displayable, and the network receives inputs on an expected scale.

How it works step by step

  1. Find the smallest and the largest value (or two percentiles such as 1% and 99%, to resist outliers).
  2. Subtract the smallest and divide by the range.
  3. Multiply by the target range and add its start.

Mathematical formulation

x' = a + \frac{(x - x_{\min})(b - a)}{x_{\max} - x_{\min}}

In deep learning, “standardisation” with the per-channel mean and standard deviation, computed on the training set only, is often used:

x' = \frac{x - \mu_{train}}{\sigma_{train}}

such as the well-known per-channel ImageNet values. Computing them on all the data (including the test set) is a form of data leakage.

Computational complexity

One pass to find the two bounds O(HW) then one pass for the transform.

Advantages

  • Simple, and guarantees a fixed range.
  • Essential when combining images from different devices.

Limitations

  • Very sensitive to outliers: a single bright pixel compresses the rest of the image.
  • Normalising each image separately erases real intensity differences that may matter (such as tissue density in CT).

When do you use it?

For display, and before feeding non-natural images (medical, thermal, satellite) to any model. In CT, use window/level in Hounsfield units instead of per-image normalisation.

Code example (Python + OpenCV)

import numpy as np
lo, hi = np.percentile(x, (1, 99))
x01 = np.clip((x - lo) / (hi - lo + 1e-8), 0, 1)

Applications

Preparing model inputs, displaying medical images with a wide range.

Limitations

Sensitive to outliers: a single outlier pixel compresses the rest of the values.

References

  1. R. Szeliski (2022).Computer Vision: Algorithms and Applications (2nd ed.). Springer, Texts in Computer Science. doi:10.1007/978-3-030-34372-9
  2. I. Goodfellow, Y. Bengio, A. Courville (2016).Deep Learning. MIT Press. www.deeplearningbook.org

Related lessons

Try it in image processing