The following example shows various ways of adding and multiplying images. The given example uses 3D images but the functionality generalizes for 2D images.

Set up 2 identical images

   1 [someone@localhost] e2.py
   2 
   3 Welcome to EMAN2
   4 Prompt provided by IPython
   5 Enter '?' for ipython help
   6 
   7 In [3]:  e = EMData()
   8 
   9 In [4]:  e.set_size(32,32,32)
  10 
  11 In [5]:  e.process_inplace('testimage.axes')
  12 
  13 In [6]:  f = e.copy() # f is precise replica of e

or try a = test_image_3d(2), a = test_image(0) etc - see

Make e different to f

   1 In [7]:  t = Transform({"type":"eman","alt":45,"phi":20,"az":11})
   2 
   3 In [8]:  t.set_trans(1,-2,5)
   4 
   5 In [9]:  t.set_mirror(True)
   6 
   7 In [10]:  e.transform(t)
   8 
   9 In [11]: e.mult(2.5) # multiply all pixel values by 2.5
  10 
  11 In [12]: e.add(13) # Adds 13 to all pixels

Add and multiply images

   1 In [13]: g = f + e # add two images, the result is stored in g
   2 
   3 In [14]: display(g) # observe g
   4 
   5 In [15]: f.add(e) # Add the pixels of e into f directly 
   6 
   7 In [16]: f.mult(e) # Multiple the pixels in f by the pixels in e
   8 
   9 In [17]: g = f * e # Multiple the pixels in f by the pixels in e and store the result in g