User Tools

Site Tools


eman2:tutorials_rotatetranslate

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.

#!python
[someone@localhost]# e2.py

Welcome to EMAN2
Prompt provided by IPython
Enter '?' for ipython help


In [3]:  e = test_image_3d() # 3D test image

In [4]:  t = Transform({"type":"eman","az":45,"alt":90})

In [5]:  t.set_trans(1,-2,5)

In [6]:  t.set_scale(2.0)

In [7]:  e.transform(t)

In [8]:  display(e)

This second example is a 2D example.

#!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. This can be useful when you wish to operate on a copy of the original image, as opposed to altering it.

#!python

In [15]:  t = Transform(....) # Construct a transform as above

In [16]:  out_of_place = e.process("xform",{"transform":t}) # Out of place

In [17]:  e.process_inplace("xform",{"transform":t}) # Inplace

In [18]:  e.transform(t) # exactly the same as line above
eman2/tutorials_rotatetranslate.txt · Last modified: by steveludtke