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