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

Module Affine

source code

This module contains the AffineTransform class and a set of factory functions used to create AffineTransform instances given different sets of parameters. Most factory functions require information that specifies the transformation and a size for the output image.

Classes [hide private]
  AffineTransform
The AffineTransform class is used to transform images and points_b back and and forth between different coordinate systems.
  _AffineTest
Functions [hide private]
 
AffineNormalizePoints(points_b)
Create a transform that centers a set of points_b such that there mean is (0,0) and then scale such that there average distance from (0,0) is 1.0
source code
 
AffineTranslate(dx, dy, new_size, interpolate=2)
Create a simple translation transform
source code
 
AffineScale(scale, new_size, center=None, interpolate=2)
Create a simple scale transform.
source code
 
AffineNonUniformScale(sx, sy, new_size, interpolate=2)
Create a scale transform with different values for the x and y directions.
source code
 
AffineRotate(theta, new_size, center=None, interpolate=2)
Create a rotation about the origin.
source code
 
AffineFromRect(rect, new_size, interpolate=2)
Create a transform from a source rectangle to a new image.
source code
 
AffineFromTile(center, new_size, interpolate=2)
Extract an image tile centered on a point.
source code
 
AffineFromPoints(src1, src2, dst1, dst2, new_size, interpolate=2)
An affine transform that will rotate, translate, and scale to map one set of points_b to the other.
source code
 
AffineFromPointsLS(src, dst, new_size, interpolate=2, normalize=True)
An affine transform that will rotate, translate, and scale to map one set of points_b to the other.
source code
 
AffineFromPointsRANSAC(src, dst, new_size, interpolate=2, normalize=True, tol=0.15)
An affine transform that will rotate, translate, and scale to map one set of points_b to the other.
source code
 
AffineFromPointsLMeDs(src, dst, new_size, interpolate=2, normalize=True)
An affine transform that will rotate, translate, and scale to map one set of points_b to the other.
source code
 
AffinePerturb(Dscale, Drotate, Dtranslate, new_size, mirror=False, flip=False, rng=None)
Generates an link.AffineTrasform that slightly perturbs the image.
source code
Variables [hide private]
  __package__ = 'pyvision.types'
Function Details [hide private]

AffineNormalizePoints(points_b)

source code 

Create a transform that centers a set of points_b such that there mean is (0,0) and then scale such that there average distance from (0,0) is 1.0

Parameters:
  • points_b - list of link.Point to normalize
Returns:
an AffineTransform object

AffineTranslate(dx, dy, new_size, interpolate=2)

source code 

Create a simple translation transform

Parameters:
  • dx - translation in the x direction
  • dy - translation in the y direction
  • new_size - new size for the image
  • interpolate - PIL interpolate to use

AffineScale(scale, new_size, center=None, interpolate=2)

source code 

Create a simple scale transform.

Parameters:
  • scale - the amount to scale the image.
  • new_size - new size for the image.
  • interpolate - PIL interpolate to use.

AffineNonUniformScale(sx, sy, new_size, interpolate=2)

source code 

Create a scale transform with different values for the x and y directions.

Parameters:
  • sx - scale in the x direction.
  • sy - scale in the y direction.
  • new_size - new size for the image.
  • interpolate - PIL interpolate to use.

AffineRotate(theta, new_size, center=None, interpolate=2)

source code 

Create a rotation about the origin.

Parameters:
  • theta - the angle to rotate the image in radians.
  • new_size - new size for the image.
  • interpolate - PIL interpolate to use.

AffineFromRect(rect, new_size, interpolate=2)

source code 

Create a transform from a source rectangle to a new image. This basically crops a rectangle out of the image and rescales it to the new size.

Parameters:
  • rect - the source link.Rect.
  • new_size - new size for the image.
  • interpolate - PIL interpolate to use.

AffineFromTile(center, new_size, interpolate=2)

source code 

Extract an image tile centered on a point.

Parameters:
  • center - the center link.Point of the tile.
  • new_size - new size for the image.
  • interpolate - PIL interpolate to use.

AffineFromPoints(src1, src2, dst1, dst2, new_size, interpolate=2)

source code 

An affine transform that will rotate, translate, and scale to map one set of points_b to the other. For example, to align eye coordinates in face images.

Find a transform (a,b,tx,ty) such that it maps the source points_b to the destination points_b:

   a*x1-b*y1+tx = x2
   b*x1+a*y1+ty = y2

The mapping between the two points_b creates a set of four linear equations with four unknowns. This set of equations is solved to find the transform.

Parameters:
  • src1 - the first link.Point in the source image.
  • src2 - the second link.Point in the source image.
  • dst1 - the first link.Point in the destination image.
  • dst2 - the second link.Point in the destination image.
  • new_size - new size for the image.
  • interpolate - PIL interpolate to use.

AffineFromPointsLS(src, dst, new_size, interpolate=2, normalize=True)

source code 

An affine transform that will rotate, translate, and scale to map one set of points_b to the other. For example, to align eye coordinates in face images.

Find a transform (a,b,tx,ty) such that it maps the source points_b to the destination points_b:

   a*x1+(-b+c)*y1+tx = x2
   (b+d)*x1+a*y1+ty = y2

This method minimizes the squared error to find an optimal fit between the points_b.

Parameters:
  • src - a list of link.Points in the source image.
  • dst - a list of link.Points in the destination image.
  • new_size - new size for the image.
  • interpolate - PIL interpolate to use.

AffineFromPointsRANSAC(src, dst, new_size, interpolate=2, normalize=True, tol=0.15)

source code 

An affine transform that will rotate, translate, and scale to map one set of points_b to the other. For example, to align eye coordinates in face images.

Find a transform (a,b,tx,ty) such that it maps the source points_b to the destination points_b:

   a*x1-b*y1+tx = x2
   b*x1+a*y1+ty = y2

This method minimizes the squared error to find an optimal fit between the points_b. Instead of a LS solver the RANSAC solver is used to produce a transformation that is robust to outliers.

Parameters:
  • src - a list of link.Points in the source image.
  • dst - a list of link.Points in the destination image.
  • new_size - new size for the image.
  • interpolate - PIL interpolate to use.

AffineFromPointsLMeDs(src, dst, new_size, interpolate=2, normalize=True)

source code 

An affine transform that will rotate, translate, and scale to map one set of points_b to the other. For example, to align eye coordinates in face images.

Find a transform (a,b,tx,ty) such that it maps the source points_b to the destination points_b:

   a*x1-b*y1+tx = x2
   b*x1+a*y1+ty = y2

This method minimizes the squared error to find an optimal fit between the points_b. Instead of a LS solver the RANSAC solver is used to produce a transformation that is robust to outliers.

Parameters:
  • src - a list of link.Points in the source image.
  • dst - a list of link.Points in the destination image.
  • new_size - new size for the image.
  • interpolate - PIL interpolate to use.

AffinePerturb(Dscale, Drotate, Dtranslate, new_size, mirror=False, flip=False, rng=None)

source code 

Generates an link.AffineTrasform that slightly perturbs the image. Primarily to generate more training images.

The perturbations include small scale, rotation, and translations. The transform can also mirror the image in the left/right direction or flip the top and bottom as other ways to generate synthetic training images.

Parameters:
  • Dscale - the difference in scale [1.0+Dscale, 1.0-Dscale].
  • Drotate - the range of difference in rotation [-Drotate,+Drotate] .
  • Dtranslate - the range of difference in translation [-Dtranslate,+Dtranslate] .
  • new_size - new size for the image.
  • mirror - Include mirror perturbations.
  • flip - Include flipped perturbations