Clamping a Computed Image Value

Image formats often restrict allowable values. A processing pipeline can compute in a larger range and clamp only when required by the output contract.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace one addition
  2. Choose when to clamp

Trace one addition

A brightening rule adding 20 to value 245 produces 265 before restriction. Clamping to an eight-bit maximum gives 255. See saturating integer arithmetic.

Choose when to clamp

Several processing steps applied in sequence may lose intended detail if each clamps unnecessarily. Test a high value followed by a later correction. Rounding intermediate and final results gives the related timing issue.[1][2]

References

  1. scikit-image Contributors, NumPy Images and Coordinate Conventions ↩
  2. scikit-image Contributors, Image Data Types and Representable Values ↩