pymagery — python imagery
1.7.0 documentation / __div__ plugin
The __div__ plugin overloads the division operator. It allows the division of two equally-sized images or the division of a constant from every pixel. If dividing two RGB images together then each color channel is handled individually.
The plugin prototype is (although never invoked directly):
When invoking the division operator it should be done with the forward-slash (/) just like any other division. The following example is how two images should be divided:
Every pixel in i is divided by the corresponding pixel in k. If the pixel value in k is zero then a divide-by-zero exception will be thrown.
It is also permitted to divide a constant value into every pixel:
This divides a value of 20 into every pixel. Note that 2 / i will not work because this would call int.__div__(image) and the int class does not under what an image is.
Change Log
- 1.7.0 — added