Package pyvision :: Package types :: Module Affine :: Class AffineTransform
[hide private]
[frames] | no frames]

Class AffineTransform

source code

The AffineTransform class is used to transform images and points_b back and and forth between different coordinate systems.

Instance Methods [hide private]
 
__init__(self, matrix, new_size, interpolate=2)
Constructor for the AffineTransform.
source code
 
__call__(self, data)
This is a simple interface to transform images or points_b.
source code
 
invert(self, data)
This is a simple interface to transform images or points_b.
source code
 
invertImage(self, im_a, use_orig=True)
Perform the inverse affine transformation on the image.
source code
 
transformImage(self, im_a, use_orig=True, inverse=False)
Transforms an image into the new coordinate system.
source code
 
transformPoint(self, pt)
Transform a point from the old image to the new image.
source code
 
transformPoints(self, pts)
Transform a set of points_b from the old image to the new image.
source code
 
invertPoint(self, pt)
Transforms a Point from the new coordinate system to the old coordinate system.
source code
 
invertPoints(self, pts)
Transforms a list of oints from the new coordinate system to the old coordinate system.
source code
 
asMatrix(self)
Returns: the transform as a 3 by 3 matrix
source code
 
__mul__(self, affine)
Used to concatenate transforms.
source code
Method Details [hide private]

__init__(self, matrix, new_size, interpolate=2)
(Constructor)

source code 

Constructor for the AffineTransform. See also the affine transform factories.

Parameters:
  • matrix - a 3-by-3 matrix that defines the transformation.
  • new_size - the size of any new images created by this affine transform.
  • interpolate - the image filtering function used for interpolating between pixels.
Returns:
an AffineTransform object

__call__(self, data)
(Call operator)

source code 

This is a simple interface to transform images or points_b. Simply call the affine transform like a function and it will try to automatically transform the argument.

Parameters:
  • data - an image, point, or list of points_b.

invert(self, data)

source code 

This is a simple interface to transform images or points_b. Simply call invert with the points_b or list of points_b and it will automatically call the correct function.

Parameters:
  • data - an image, point, or list of points_b.

transformImage(self, im_a, use_orig=True, inverse=False)

source code 

Transforms an image into the new coordinate system.

If this image was produced via an affine transform of another image, this method will attempt to trace weak references to the original image and directly compute the new image from that image to improve accuracy. To accomplish this a weak reference to the original source image and the affine matrix used for the transform are added to any image produced by this method. This can be disabled using the use_orig parameter.

Parameters:
  • im_a - an Image object
  • use_orig - (True or False) attempts to find and use the original image as the source to avoid an accumulation of errors.
Returns:
the transformed image

transformPoint(self, pt)

source code 

Transform a point from the old image to the new image.

Parameters:
  • pt - the point
Returns:
the new point

transformPoints(self, pts)

source code 

Transform a set of points_b from the old image to the new image.

Parameters:
  • pts - a list of points_b.
Returns:
a list of transformed points_b.

invertPoint(self, pt)

source code 

Transforms a Point from the new coordinate system to the old coordinate system.

Parameters:
  • pt - a single point
Returns:
the transformed point

invertPoints(self, pts)

source code 

Transforms a list of oints from the new coordinate system to the old coordinate system.

Parameters:
  • pts - a list of Points
Returns:
the transformed Points

asMatrix(self)

source code 
Returns:
the transform as a 3 by 3 matrix

__mul__(self, affine)

source code 

Used to concatenate transforms. For example:

   # This code first scales and then translates
   S = AffineScale(2.0)
   T = AffineTranslate(4,5)
   A = T*S
   new_im = A.transformImage(old_im)
Returns:
a single AffineTransform which is the the same as both affine transforms.