Image Processing Toolbox    

Image Arithmetic Truncation Rules

The results of integer arithmetic can easily overflow the data type allotted for storage. For example, the maximum value you can store in uint8 data is 255. Arithmetic operations can also result in fractional values, which cannot be represented using integer arrays.

The image arithmetic functions use these rules for integer arithmetic:

For example, if the data type is uint8, results greater than 255 (including Inf) are set to 255. The following table lists some additional examples.

Result
Class
Truncated Value
300
uint8
255
-45
uint8
0
10.5
uint8
11


  Summary of Image Arithmetic Functions Adding Images