670
Comment:
|
1664
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
{{{ [someone@localhost]$ e2.py |
= Rotating and/or Translating Images = 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 [[Eman2TransformInPython|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. {{{#!python [someone@localhost]# e2.py |
Line 8: | Line 16: |
In [3]: e = EMData() | |
Line 10: | Line 17: |
In [4]: e.set_size(32,32,32) | In [3]: e = test_image_3d() |
Line 12: | Line 19: |
In [5]: e.process_inplace('testimage.axes') | In [4]: t = Transform({"type":"eman","az":45,"alt":90}) |
Line 14: | Line 21: |
In [6]: t = Transform3D(90,30,90) | In [5]: t.set_trans(1,-2,5) |
Line 16: | Line 23: |
In [7]: t.set_posttrans(1,-2,5) | In [6]: t.set_scale(1) |
Line 18: | Line 25: |
In [8]: t.set_pretrans(2,10,-20) | In [7]: e.transform(t) |
Line 20: | Line 27: |
In [9]: e.rotate_translate(t) In [9]: display(e) |
In [8]: display(e) |
Line 26: | Line 31: |
Notes: | This second example is a '''2D''' example. |
Line 28: | Line 33: |
1. The Transform3D is initialized on line 6 with the arguments 90 (azimuth), 30 (altitude), and 90 (phi). This is ZXZ' rotation. You can do rotations using SPIDER, MRC, IMAGIC and many other conventions with the Transform3D object, but this is not demonstrated here. | {{{#!python In [9]: e = test_image() # This is a 2D test image In [10]: t = Transform({"type":"2d","alpha":45}) # Note 2D terminology In [11]: t.set_trans(3,-2) # Note 2D translation In [12]: t.set_mirror(True) In [13]: e.transform(t) In [14]: display(e) }}} == Using the Processor Framework == 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. {{{#!python In [15]: t = Transform(....) # Construct a transform as above In [16]: out_of_place = e.process("math.transform",{"transform":t}) # Out of place In [17]: e.process_inplace("math.transform",{"transform":t}) # Inplace In [18]: e.transform(t) # exactly the same as line above }}} |
Rotating and/or Translating Images
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()
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(1)
15
16 In [7]: e.transform(t)
17
18 In [8]: display(e)
This second example is a 2D example.
Using the Processor Framework
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.