When performing pixel arithmetic, the result of the operation may not fit within the pixel data type. This experiment illustrates this problem by adding a constant to all image pixels.
![]() |
![]() |
---|---|
a) | b) |
The problem with the above image is that the pixel data type is unsigned byte. With this data type we can only represent values from 0 to 255. Adding 80 to 255 gives (255+80) - 256 = 79 (wraparound), which is a dark pixel value.
To solve this wraparound effect, we can convert the pixel data type to unsigned short (16 bits) and then perform the addition.
![]() |
---|