The following example shows various ways of adding and multiplying images. The given example uses 3D images but the functionality generalizes for 2D images.
Adding and multiplying images
First I make different two example images that have the same dimensions
or try a = test_image_3d(2), a = test_image(0) etc - see the test image gallery.
Add/multiply/subtract/divide images and store the result in a new image
Add/multiply B and A, store result in A
Subtract B from A and store it in A
In [11]: C = B*-1 # multiply B by negative one, store it C In [12]: A.add(C) # equivalent to subtracting B from A In [13]: A.add(B*-1) # equivalent to line above