public class TransformUtilities extends Object
Modifier and Type | Method and Description |
---|---|
static Jama.Matrix |
affineMatrix(List<? extends IndependentPair<? extends Point2d,? extends Point2d>> data)
Construct an affine transform using a least-squares fit of the provided
point pairs.
|
static Jama.Matrix |
affineMatrixND(double[][] q,
double[][] p)
Find the affine transform between pairs of matching points in
n-dimensional space.
|
static Jama.Matrix |
affineMatrixND(List<? extends IndependentPair<? extends Coordinate,? extends Coordinate>> data)
Find the affine transform between pairs of matching points in
n-dimensional space.
|
static Jama.Matrix |
approximateRotationMatrix(Jama.Matrix approx)
Given an approximate rotation matrix Q (that doesn't necessarily conform
properly to a rotation matrix), return the best estimate of a rotation
matrix R such that the Frobenius norm is minimised: min||r-Q||^2_F.
|
static Jama.Matrix |
centeredRotationMatrix(double rot,
int width,
int height)
Construct a rotation about the centre of the rectangle defined by width
and height (i.e.
|
static Jama.Matrix |
fundamentalMatrix8Pt(List<? extends IndependentPair<Point2d,Point2d>> data)
The un-normalised 8-point algorithm for estimation of the Fundamental
matrix.
|
static Jama.Matrix |
fundamentalMatrix8PtNorm(List<? extends IndependentPair<Point2d,Point2d>> data)
The normalised 8-point algorithm for estimating the Fundamental matrix
|
static Pair<Jama.Matrix> |
getNormalisations(List<? extends IndependentPair<? extends Point2d,? extends Point2d>> data)
Generates the data for normalisation of the points such that each matched
point is centered about the origin and also scaled be be within
Math.sqrt(2) of the origin.
|
static Jama.Matrix |
homographyMatrix(List<? extends IndependentPair<? extends Point2d,? extends Point2d>> data)
Compute the least-squares estimate (the normalised Direct Linear
Transform approach) of the homography between a set of matching data
points.
|
static Jama.Matrix |
homographyMatrixNorm(List<? extends IndependentPair<? extends Point2d,? extends Point2d>> data)
Compute the least-squares estimate (the normalised Direct Linear
Transform approach) of the homography between a set of matching data
points.
|
static Jama.Matrix |
homographyToAffine(Jama.Matrix homography)
Given a point x and y, calculate the 2x2 affine transform component of
the 3x3 homography provided such that:
H = AH_p H = { {h11,h12,h13}, {h21,h22,h23}, {h31,h32,h33} } H_p = {
{1,0,0}, {0,1,0}, {h31,h32,1} } A = { {a11,a12,a13}, {a21,a22,a23},
{0,0,1} }
so
|
static Jama.Matrix |
homographyToAffine(Jama.Matrix homography,
double x,
double y)
Estimate the closest (in the least-squares sense) affine transform for a
homography.
|
static Jama.Matrix |
makeTransform(Rectangle from,
Rectangle to)
Create a transform to transform from one rectangle to another.
|
static IndependentPair<Point2d,Point2d> |
normalise(IndependentPair<Point2d,Point2d> data,
Pair<Jama.Matrix> normalisations)
Normalise the data, returning a normalised copy.
|
static List<? extends IndependentPair<Point2d,Point2d>> |
normalise(List<? extends IndependentPair<Point2d,Point2d>> data,
Pair<Jama.Matrix> normalisations)
Normalise the data, returning a normalised copy.
|
static Jama.Matrix |
rigidMatrix(double[][] q,
double[][] p)
Compute the least-squares rigid alignment between two sets of matching
points in N-dimensional space.
|
static Jama.Matrix |
rigidMatrix(List<? extends IndependentPair<? extends Coordinate,? extends Coordinate>> data)
Compute the least-squares rigid alignment between two sets of matching
points in N-dimensional space.
|
static Jama.Matrix |
rodrigues(double[] r)
Convert a Rodrigues rotation vector to a rotation matrix.
|
static double[] |
rodrigues(Jama.Matrix R)
Convert a 3D rotation matrix to a Rodrigues rotation vector, which is
oriented along the rotation axis, and has magnitude equal to the rotation
angle.
|
static Jama.Matrix |
rotationMatrix(double rot)
Construct a rotation about 0, 0.
|
static Jama.Matrix |
rotationMatrixAboutPoint(double rot,
float tx,
float ty)
Construct a rotation about the centre of the rectangle defined by width
and height (i.e.
|
static Jama.Matrix |
scaleMatrix(double d,
double e)
Construct a homogeneous scaling transform with the given amounts of
scaling.
|
static Jama.Matrix |
scaleMatrixAboutPoint(double sx,
double sy,
int tx,
int ty)
Create a scaling centered around a point.
|
static Jama.Matrix |
scaleMatrixAboutPoint(double sx,
double sy,
Point2d point)
Create a scaling centered around a point.
|
static Jama.Matrix |
translateMatrix(double x,
double y)
Construct a translation.
|
static Jama.Matrix |
translateToPointMatrix(Point2d from,
Point2d to)
Given two points, get a transform matrix that takes points from point a
to point b
|
public static Jama.Matrix rotationMatrix(double rot)
rot
- The amount of rotation in radians.public static Jama.Matrix translateToPointMatrix(Point2d from, Point2d to)
from
- from this pointto
- to this pointpublic static Jama.Matrix translateMatrix(double x, double y)
x
- The amount to translate in the x-direction.y
- The amount to translate in the y-direction.public static Jama.Matrix centeredRotationMatrix(double rot, int width, int height)
rot
- The amount of rotation in radians.width
- The width of the rectangle.height
- The height of the rectangle.public static Jama.Matrix scaleMatrixAboutPoint(double sx, double sy, int tx, int ty)
sx
- x-scalesy
- y-scaletx
- x-positionty
- y-positionpublic static Jama.Matrix scaleMatrixAboutPoint(double sx, double sy, Point2d point)
sx
- x-scalesy
- y-scalepoint
- The pointpublic static Jama.Matrix rotationMatrixAboutPoint(double rot, float tx, float ty)
rot
- The amount of rotation in radians.tx
- the x translationty
- the y translation@Reference(author="Sp\"ath, Helmuth", title="Fitting affine and orthogonal transformations between two sets of points.", type=Article, year="2004", journal="Mathematical Communications", publisher="Croatian Mathematical Society, Division Osijek, Osijek; Faculty of Electrical Engineering, University of Osijek, Osijek", pages={"27","34"}, volume="9", number="1") public static Jama.Matrix affineMatrixND(double[][] q, double[][] p)
q
- first set of pointsp
- second set of points@Reference(author="Sp\"ath, Helmuth", title="Fitting affine and orthogonal transformations between two sets of points.", type=Article, year="2004", journal="Mathematical Communications", publisher="Croatian Mathematical Society, Division Osijek, Osijek; Faculty of Electrical Engineering, University of Osijek, Osijek", pages={"27","34"}, volume="9", number="1") public static Jama.Matrix affineMatrixND(List<? extends IndependentPair<? extends Coordinate,? extends Coordinate>> data)
data
- pairs of matching n-dimensional Coordinate
s@Reference(type=Article, author={"Berthold K. P. Horn","H.M. Hilden","Shariar Negahdaripour"}, title="Closed-Form Solution of Absolute Orientation using Orthonormal Matrices", year="1988", journal="JOURNAL OF THE OPTICAL SOCIETY AMERICA", pages={"1127","1135"}, number="7", volume="5") public static Jama.Matrix rigidMatrix(double[][] q, double[][] p)
q
- first set of pointsp
- second set of points@Reference(type=Article, author={"Berthold K. P. Horn","H.M. Hilden","Shariar Negahdaripour"}, title="Closed-Form Solution of Absolute Orientation using Orthonormal Matrices", year="1988", journal="JOURNAL OF THE OPTICAL SOCIETY AMERICA", pages={"1127","1135"}, number="7", volume="5") public static Jama.Matrix rigidMatrix(List<? extends IndependentPair<? extends Coordinate,? extends Coordinate>> data)
data
- set of points matching pointspublic static Jama.Matrix affineMatrix(List<? extends IndependentPair<? extends Point2d,? extends Point2d>> data)
data
- Data to calculate affine matrix from.public static Jama.Matrix scaleMatrix(double d, double e)
d
- Scaling in the x-direction.e
- Scaling in the y-direction.public static Pair<Jama.Matrix> getNormalisations(List<? extends IndependentPair<? extends Point2d,? extends Point2d>> data)
data
- public static List<? extends IndependentPair<Point2d,Point2d>> normalise(List<? extends IndependentPair<Point2d,Point2d>> data, Pair<Jama.Matrix> normalisations)
data
- normalisations
- public static IndependentPair<Point2d,Point2d> normalise(IndependentPair<Point2d,Point2d> data, Pair<Jama.Matrix> normalisations)
data
- the datanormalisations
- the normalisation matricespublic static Jama.Matrix fundamentalMatrix8PtNorm(List<? extends IndependentPair<Point2d,Point2d>> data)
data
- public static Jama.Matrix fundamentalMatrix8Pt(List<? extends IndependentPair<Point2d,Point2d>> data)
data
- public static Jama.Matrix homographyMatrixNorm(List<? extends IndependentPair<? extends Point2d,? extends Point2d>> data)
data
- the matching pointspublic static Jama.Matrix homographyMatrix(List<? extends IndependentPair<? extends Point2d,? extends Point2d>> data)
normalise(List, Pair)
). For
un-normalised data, use homographyMatrixNorm(List)
instead.data
- the matching pointspublic static Jama.Matrix homographyToAffine(Jama.Matrix homography)
homography
- public static Jama.Matrix homographyToAffine(Jama.Matrix homography, double x, double y)
homography
- the homographyx
- y
- public static Jama.Matrix makeTransform(Rectangle from, Rectangle to)
from
- first rectangleto
- second rectanglepublic static Jama.Matrix approximateRotationMatrix(Jama.Matrix approx)
Fundamentally, this works by performing an SVD of the matrix, setting all the singular values to 1 and then reconstructing the input.
approx
- the initial guesspublic static double[] rodrigues(Jama.Matrix R)
R
- the rotation matrixpublic static Jama.Matrix rodrigues(double[] r)
r
- the Rodrigues rotation vector