Class AlgorithmQuadraticFit
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.AlgorithmQuadraticFit
-
public class AlgorithmQuadraticFit extends java.lang.Object
Approximate a set of points by a quadric surface. The surface is implicitly represented as the quadratic equation0 = C[0] + C[1]*X + C[2]*Y + C[3]*Z + C[4]*X^2 + C[5]*Y^2 + C[6]*Z^2 + C[7]*X*Y + C[8]*X*Z + C[9]*Y*Z
The coefficients are estimated using a least-squares algorithm. There is one degree of freedom in the coefficients. It is removed by requiring the vector C = (C[0],...,C[9]) to be unit length. The least-square problem is to minimize E(C) = C^t M C with M = (sum_i V_i)(sum_i V_i)^t and
V = (1, X, Y, Z, X^2, Y^2, Z^2, X*Y, X*Z, Y*Z)
Minimum value is the smallest eigenvalue of M and C is a corresponding unit length eigenvector.
The quadratic equation can be factored into P^T A P + B^T P + K = 0 where P = (X,Y,Z), K = C[0], B = (C[1],C[2],C[3]), and A is a 3x3 symmetric matrix with A00 = C[4], A11 = C[5], A22 = C[6], A01 = C[7]/2, A02 = C[8]/2, and A12 = C[9]/2. Matrix A = R^T D R where R is orthogonal and D is diagonal (using an eigendecomposition). Define V = R P = (v0,v1,v2), E = R B = (e0,e1,e2), D = diag(d0,d1,d2), and f = K to obtain
d0 v0^2 + d1 v1^2 + d2 v^2 + e0 v0 + e1 v1 + e2 v2 + f = 0
The characterization of the surface depends on the signs of the d_i. For the MRI brain segmentation, the signs d_i are all positive, thereby producing an ellipsoid.
The quadratic equation can finally be factored into
(P-G)^T R^T D R (P-G) = L
where G is the center of the surface, R is the orientation matrix, D is a diagonal matrix, and L is a constant.
-
-
Field Summary
Fields Modifier and Type Field Description protected float[]
m_afCoeff
the coeffficients of the approximating quadratic equation.protected float[]
m_afDiagonal
DOCUMENT ME!protected float
m_fConstant
DOCUMENT ME!protected WildMagic.LibFoundation.Mathematics.Vector3f
m_kCenter
The center G, orientation R, diagonal matrix D, and constant L in the factorization (P-G)^T R^T D R (P-G) = L.protected WildMagic.LibFoundation.Mathematics.Matrix3f
m_kOrient
DOCUMENT ME!
-
Constructor Summary
Constructors Constructor Description AlgorithmQuadraticFit(java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> kPoints)
Fit a set of 3D points with a quadric surface.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WildMagic.LibFoundation.Mathematics.Vector3f
getCenter()
Get the center of the quadric surface.float
getCoefficient(int i)
Get the coefficients of the quadratic equation that represents the approximating quadric surface.float
getConstant()
Get the constant term for the factored quadratic equation.float
getDiagonal(int i)
Get a diagonal entry for the quadric surface.WildMagic.LibFoundation.Mathematics.Matrix3f
getOrient()
Get the orientation of the quadric surface.
-
-
-
Field Detail
-
m_afCoeff
protected float[] m_afCoeff
the coeffficients of the approximating quadratic equation.
-
m_afDiagonal
protected float[] m_afDiagonal
DOCUMENT ME!
-
m_fConstant
protected float m_fConstant
DOCUMENT ME!
-
m_kCenter
protected WildMagic.LibFoundation.Mathematics.Vector3f m_kCenter
The center G, orientation R, diagonal matrix D, and constant L in the factorization (P-G)^T R^T D R (P-G) = L.
-
m_kOrient
protected WildMagic.LibFoundation.Mathematics.Matrix3f m_kOrient
DOCUMENT ME!
-
-
Constructor Detail
-
AlgorithmQuadraticFit
public AlgorithmQuadraticFit(java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> kPoints)
Fit a set of 3D points with a quadric surface. The various representations of the surface can be accessed by member functions.- Parameters:
kPoints
- a vector of points, each vector element is of type Point3f
-
-
Method Detail
-
getCenter
public final WildMagic.LibFoundation.Mathematics.Vector3f getCenter()
Get the center of the quadric surface. This is the vector G in the factorization (P-G)^T R^T D R (P-G) = L.- Returns:
- the center point
-
getCoefficient
public final float getCoefficient(int i)
Get the coefficients of the quadratic equation that represents the approximating quadric surface.- Parameters:
i
- the coefficient index (0 <= i < 10)- Returns:
- the value of the coefficient
-
getConstant
public final float getConstant()
Get the constant term for the factored quadratic equation. This is the L term in (P-G)^T R^T D R (P-G) = L.- Returns:
- the constant term
-
getDiagonal
public final float getDiagonal(int i)
Get a diagonal entry for the quadric surface. This is a diagonal term for the matrix D in the factorization A = R^T D R where A is the coefficient matrix for the quadratic term in the equation.- Parameters:
i
- the index of the diagonal (0 <= i < 3)- Returns:
- the diagonal entry
-
getOrient
public final WildMagic.LibFoundation.Mathematics.Matrix3f getOrient()
Get the orientation of the quadric surface. This is the matrix R in the factorization A = R^T D R where A is the coefficient matrix for the quadratic term in the equation.- Returns:
- the orientation matrix
-
-