Differences between revisions 6 and 7
Revision 6 as of 2008-11-26 04:42:30
Size: 562
Editor: localhost
Comment: converted to 1.6 markup
Revision 7 as of 2009-02-04 21:06:03
Size: 1217
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
{{{
[someone@localhost]$ e2.py
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 =
{{{#!python
[someone@localhost] e2.py
Line 12: Line 15:
In [5]: f = e.copy() In [5]: e.process_inplace('testimage.axes')
Line 14: Line 17:
In [5]: e.process_inplace('testimage.axes') In [6]: f = e.copy() # f is precise replica of e
Line 16: Line 19:
''or try e.process_inplace('testimage.scurve') or e.process_inplace('testimage.gradient')''
{{{
In [6]: t = Transform3D(90,30,90)
''or try a = test_image_3d(2), a = test_image(0) etc - see''
Line 20: Line 21:
In [7]: t.set_posttrans(1,-2,5) = Make e different to f =
Line 22: Line 23:
In [8]: t.set_pretrans(2,10,-20) {{{#!python
In [7]: t = Transform({"type":"eman","alt":45,"phi":20,"az":11})
Line 24: Line 26:
In [9]: e.rotate_translate(t) In [8]: t.set_trans(1,-2,5)
Line 26: Line 28:
In [10]: e.mult(2.5) In [9]: t.set_mirror(True)
Line 28: Line 30:
In [11]: g = f + e In [10]: e.transform(t)
Line 30: Line 32:
In [12]: display(g) In [11]: e.mult(2.5) # multiply all pixel values by 2.5
Line 32: Line 34:
In [12]: e.add(13) # Adds 13 to all pixels
Line 33: Line 36:

= Add and multiply images =

{{{#!python
In [13]: g = f + e # add two images, the result is stored in g

In [14]: display(g) # observe g

In [15]: f.add(e) # Add the pixels of e into f directly

In [16]: f.mult(e) # Multiple the pixels in f by the pixels in e

In [17]: g = f * e # Multiple the pixels in f by the pixels in e and store the result in g
}}}

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

EMAN2/Tutorials/AddAndMultiply (last edited 2009-03-06 17:36:06 by DavidWoolford)