2.3 Image Arithmetic

Beware of arithmetic overflow or underflow on pixel values. Pixels are unsigned and have a limited number of bits (typically 8 for greyscale or 8 bits per color R-G-B). For example. 128+129=256 which overflows to 1. Hence an operation may need numerical scaling of all pixel values as part of the calculation.


The difference operation, absolute value of pixel by pixel difference, is the best operation for finding differences between compex images which differ in a small way. For binary images the XOR operation is used.

It is much easier to use "JASC Paint Shop Pro" for these operations, rather than use Photoshop.