pymagery — python imagery
1.8.0 documentation / __add__ plugin
The __add__ plugin overloads the addition operator. It allows the addition of two equally-sized images together or the addition of a constant to every pixel. If adding two RGB images together then each color channel is handled individually. If adding two monochrome images together then the result is effectively a logical OR.
The plugin prototype is (although never invoked directly):
When invoking the addition operator it should be done with the plus sign (+) just like any other addition. The following example is how two images should be added together:
Every pixel in i is added to the corresponding pixel in k. If the pixel value exceeds the maximum then it is truncated to the maximum allowed value.
It is also permitted to add a constant value to every pixel:
This adds a value of 20 to every pixel. Again, if the value exceeds the maximum value then the value is truncated to the maximum. If the value falls below zero (by adding a negative value) then the value is truncated to zero. Note that 2 + i will not work because this would call int.__add__(image) and the int class does not under what an image is.
Change Log
- 1.7.0 — added