Differences between revisions 11 and 17 (spanning 6 versions)
Revision 11 as of 2009-03-24 02:10:23
Size: 1664
Comment:
Revision 17 as of 2015-05-04 18:17:02
Size: 1701
Comment: changed math.transform to xform
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Rotating and/or Translating Images = <<TableOfContents>>

= Transforming Images (Applying Rotation, Translation, Scale and Mirroring) =
Line 17: Line 19:
In [3]: e = test_image_3d() In [3]: e = test_image_3d() # 3D test image
Line 23: Line 25:
In [6]: t.set_scale(1) In [6]: t.set_scale(2.0)
Line 52: Line 54:
You can use the processor framework to process an EMData object in and out of place. In the latter case it is more efficient to use the processing framework as opposed to make a copy followed by EMData.transform. You can use the processor framework to process an EMData object in and out of place. This can be useful when you wish to operate on a copy of the original image, as opposed to altering it.
Line 58: Line 60:
In [16]: out_of_place = e.process("math.transform",{"transform":t}) # Out of place In [16]: out_of_place = e.process("xform",{"transform":t}) # Out of place
Line 60: Line 62:
In [17]: e.process_inplace("math.transform",{"transform":t}) # Inplace In [17]: e.process_inplace("xform",{"transform":t}) # Inplace

Transforming Images (Applying Rotation, Translation, Scale and Mirroring)

What follows is a very simply demonstration of using the Transform object to transform EMData (image) objects. A very thorough explanation of using the Transform is presented in Using the EMAN2 Transform class and you are encouraged to at least be aware of that page's existence.

Using EMData.transform

The first example here is a 3D example.

   1 [someone@localhost]# e2.py
   2 
   3 Welcome to EMAN2
   4 Prompt provided by IPython
   5 Enter '?' for ipython help
   6 
   7 
   8 In [3]:  e = test_image_3d() # 3D test image
   9 
  10 In [4]:  t = Transform({"type":"eman","az":45,"alt":90})
  11 
  12 In [5]:  t.set_trans(1,-2,5)
  13 
  14 In [6]:  t.set_scale(2.0)
  15 
  16 In [7]:  e.transform(t)
  17 
  18 In [8]:  display(e)

This second example is a 2D example.

   1 In [9]:  e = test_image() # This is a 2D test image
   2 
   3 In [10]:  t = Transform({"type":"2d","alpha":45}) # Note 2D terminology
   4 
   5 In [11]:  t.set_trans(3,-2) # Note 2D translation
   6 
   7 In [12]:  t.set_mirror(True)
   8 
   9 In [13]:  e.transform(t)
  10 
  11 In [14]:  display(e)

Using the Processor Framework

You can use the processor framework to process an EMData object in and out of place. This can be useful when you wish to operate on a copy of the original image, as opposed to altering it.

   1 In [15]:  t = Transform(....) # Construct a transform as above
   2 
   3 In [16]:  out_of_place = e.process("xform",{"transform":t}) # Out of place
   4 
   5 In [17]:  e.process_inplace("xform",{"transform":t}) # Inplace
   6 
   7 In [18]:  e.transform(t) # exactly the same as line above

EMAN2/Tutorials/RotateTranslate (last edited 2015-05-04 18:17:02 by StephenMurray)