Class AlgorithmRegLeastSquares
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.registration.AlgorithmRegLeastSquares
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmRegLeastSquares extends AlgorithmBase
"Least-Squares Fitting of 2 3-D Point Sets", K. S. Arun PAMI-9(5), September, 1987 (698-700)Rotation and translation but not scale. That is, this is a rigid transformation based on two homologous datasets.
- Version:
- 1.0 October 1998
- Author:
- Delia McGarry idea to use point matching for surgical cases is from the Virginia Neurological Institute,
Charlottesville, VA Registers 1. 2 sets of 2D points (number of points in sets should be equal and greater
or equal to 3 and non-colinear) 2. 2 sets of 3D points (number of points in sets should be equal and
greater or equal to 4 and non-colinear) Software can handle cases which are are coplanar but are not
colinear.
USAGE: AlgorithmleastSquares LSMatch = new AlgorithmLeastSquares(coordsA, coordsB); LSMatch.run(); where coordsA = double[3][n] or Vector3f[n]
USAGE FOR SUBSEQUENT EXECUTIONS: LSMatch.setup(coordsA, coordsB); LSMatch.run();
-
-
Field Summary
Fields Modifier and Type Field Description private int
dim
The number of dimensions (2D or 3D).private int
numCoords
DOCUMENT ME!private double[][]
pointSetA
Input point set A (2D or 3D)private double[][]
pointSetB
Input point set B (2D or 3D)private TransMatrix
xfrmBA
The transformation matrix that describes the transform from point set B to point set A.-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmRegLeastSquares(double[][] coordsA, double[][] coordsB, int dim2or3)
AlgorithmRegLeastSquares - Constructor.AlgorithmRegLeastSquares(WildMagic.LibFoundation.Mathematics.Vector3f[] coordsA3D, WildMagic.LibFoundation.Mathematics.Vector3f[] coordsB3D, int dim2or3)
AlgorithmRegLeastSquares - Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private TransMatrix
buildXfrm(double[] p1, double[] p2, Jama.Matrix R)
Builds 4x4 transformation matrix from R and T where T=p2-R*p1.void
calculateResiduals()
CalculateResiduals.double
EuclideanDistance(double[] ptA, double[] ptB)
EuclideanDistance.void
finalize()
Prepares this class for destruction.TransMatrix
getTransformBtoA()
Accesses xfrm from point set B to point set A.void
matchBtoA()
matchBtoA pA and pB are 2 3D point sets (pointSetA and B).void
runAlgorithm()
Starts the program.void
setTransformBtoA(TransMatrix xfrm)
Set transform from point set A to point set B.int
setup(double[][] coordsA, double[][] coordsB)
Checks if pointSetA is same dimension as pointSetB sets pointSetA and pointSetB.int
setup(WildMagic.LibFoundation.Mathematics.Vector2f[] coordsA, WildMagic.LibFoundation.Mathematics.Vector2f[] coordsB)
Checks if pointSetA is same dimension as pointSetB sets pointSetA and pointSetB.int
setup(WildMagic.LibFoundation.Mathematics.Vector3f[] coordsA, WildMagic.LibFoundation.Mathematics.Vector3f[] coordsB)
Checks if pointSetA is same dimension as pointSetB sets pointSetA and pointSetB.static double
SQR(double x)
SQR = x^2.-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
numCoords
private int numCoords
DOCUMENT ME!
-
dim
private int dim
The number of dimensions (2D or 3D).
-
pointSetA
private double[][] pointSetA
Input point set A (2D or 3D)
-
pointSetB
private double[][] pointSetB
Input point set B (2D or 3D)
-
xfrmBA
private TransMatrix xfrmBA
The transformation matrix that describes the transform from point set B to point set A.
-
-
Constructor Detail
-
AlgorithmRegLeastSquares
public AlgorithmRegLeastSquares(double[][] coordsA, double[][] coordsB, int dim2or3)
AlgorithmRegLeastSquares - Constructor.- Parameters:
coordsA
- - double[dim][n] 3D or 2D point setcoordsB
- - double[dim][n] 3D or 2D point setdim2or3
- - indicates whether data set is 2D or 3D
-
AlgorithmRegLeastSquares
public AlgorithmRegLeastSquares(WildMagic.LibFoundation.Mathematics.Vector3f[] coordsA3D, WildMagic.LibFoundation.Mathematics.Vector3f[] coordsB3D, int dim2or3)
AlgorithmRegLeastSquares - Constructor.- Parameters:
coordsA3D
- Vector3f[n] 3D point setcoordsB3D
- Vector3f[n] 3D point setdim2or3
- indicates whether data set is 2D or 3D
-
-
Method Detail
-
SQR
public static double SQR(double x)
SQR = x^2.- Parameters:
x
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
buildXfrm
private TransMatrix buildXfrm(double[] p1, double[] p2, Jama.Matrix R)
Builds 4x4 transformation matrix from R and T where T=p2-R*p1.- Parameters:
p1
- from Matchp2
- from MatchR
- =rotation matrix from Match- Returns:
- DOCUMENT ME!
-
calculateResiduals
public void calculateResiduals()
CalculateResiduals.
-
EuclideanDistance
public double EuclideanDistance(double[] ptA, double[] ptB)
EuclideanDistance.- Parameters:
ptA
- DOCUMENT ME!ptB
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
finalize
public void finalize()
Prepares this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
getTransformBtoA
public TransMatrix getTransformBtoA()
Accesses xfrm from point set B to point set A.- Returns:
- xfrmBA
-
matchBtoA
public void matchBtoA()
matchBtoA pA and pB are 2 3D point sets (pointSetA and B).p1[i]=(1/numCoords)*(sum from j = 0 to j = numCoords - 1 of pB[i][j]) p2[i]=(1/numCoords)*(sum from j = 0 to j = numCoords - 1 of pA[i][j])
q1[i][j] =pB[i][j]-p1[i] q2[i][j]=pA[i][j]-p2[i]
-
runAlgorithm
public void runAlgorithm()
Starts the program.- Specified by:
runAlgorithm
in classAlgorithmBase
-
setTransformBtoA
public void setTransformBtoA(TransMatrix xfrm)
Set transform from point set A to point set B.- Parameters:
xfrm
- transform to copy
-
setup
public int setup(double[][] coordsA, double[][] coordsB)
Checks if pointSetA is same dimension as pointSetB sets pointSetA and pointSetB.- Parameters:
coordsA
- first 3D point setcoordsB
- second 3D point set- Returns:
- distinguishing reason for error
-
setup
public int setup(WildMagic.LibFoundation.Mathematics.Vector3f[] coordsA, WildMagic.LibFoundation.Mathematics.Vector3f[] coordsB)
Checks if pointSetA is same dimension as pointSetB sets pointSetA and pointSetB.- Parameters:
coordsA
- first 3D point setcoordsB
- second 3D point Set- Returns:
- int distinguishing reason for error
-
setup
public int setup(WildMagic.LibFoundation.Mathematics.Vector2f[] coordsA, WildMagic.LibFoundation.Mathematics.Vector2f[] coordsB)
Checks if pointSetA is same dimension as pointSetB sets pointSetA and pointSetB.- Parameters:
coordsA
- first 2D point setcoordsB
- second 2D point Set- Returns:
- int distinguishing reason for error
-
-