Class SpatialXform

java.lang.Object
  extended by SpatialXform

public class SpatialXform
extends java.lang.Object

Class SpatialXform is used for doing non-linear order warping These methods are derived from:

 Digital Image Warping, George Wolberg,
 IEEE Computer Press Monograph, Los Alamitos, CA, 1990.
 ISBN-0-8186-8944-7

 See Section 3.6 Polygonal Transformations pp 61-75. A bivariate
 polygonal transformation for performing spatial interpolation

 This generates (aV, bV) from 6 landmarks.

 u=  SUM     SUM    aU_ij * (x**i) * (y**j)
    i=0:n  i=0:n-1

 v=  SUM     SUM    bV_ij * (x**i) * (y**j)
    i=0:n  i=0:n-1

 We use (n=2) (for n=1, this is a 3x3 Affine xform).

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The Flicker Mozilla and Legal files are available on http://open2dprot.sourceforge.net/Flicker

Version:
$Date$ $Revision$
Author:
P. Lemkin (LECB/NCI), G. Thornwall (SAIC), Frederick, MD
See Also:
Flicker Home

Field Summary
(package private)  double[][] aU
          [MXTERMS][MXTERMS]coefficients
(package private)  double[][] bV
          [MXTERMS][MXTERMS] coefficients
private static Flicker flk
          Global instance
private static Landmark lms
          landmarks to use
 int MXTERMS
          Maximum number of terms in spatial transform
(package private)  int nU
          # of CTRL points in x1[], y2[], zU[]
(package private)  int nV
          # of CTRL points in y1[], y2[], zV[]
private static Util util
           
(package private)  double[] wM
          (dynamic) weights
(package private)  double[] x1
          x1 is list of x coordinates for image 1
(package private)  double[] x2
          x2 is list of x coordinates for image 2
(package private)  double[] y1
          y1 is list of x coordinates for image 1
(package private)  double[] y2
          y2 is list of x coordinates for image 2
(package private)  double[] z12U
          OUTPUT: z[]= f(x[],y[])
(package private)  double[] z12V
          OUTPUT: z[]= f(x[],y[])
 
Constructor Summary
SpatialXform(Flicker flk)
          SpatialXform() - constructor.
 
Method Summary
(package private) static double basis(int f, double x, double y)
          basis() - return (x,y) value of f'th orthogonal basis function.
 void cleanup()
          cleanup() - destroy data structures
(package private) static double coef(int k, int nM, double[] xM, double[] yM, double[] wM, double[] zM, double[][] aM)
          coef() - Find kth mapping function coefficient (Eq.
 boolean computeSurfaceWarp(int nM, int terms, double[] xM, double[] yM, double[] zM, double[][] aM, double delta, int xSize, int ySize, double[] sOut)
          computeSurfaceWarp() - compute surface warp from data.
 int evalPoly(int n, int xInt, int yInt, double[][] aM)
          evalPoly() - eval f_n(x,y)
 int fitWarpLSQ(int nM, double[] xM, double[] yM, double[] zM, double[][] aM, double delta)
          fitWarpLSQ() - weighted LSQ spatial transform w/ orthogonal polynomials Based on algorithm described by Ardeshir Goshtasby in "Image resgistration by local approximation methods", Image and Vision computing, Vold 6, No.
 double[][] get_aU()
          get_aU() - get aU[MXTERMS][MXTERMS] array this is solution to:
 double[][] get_bV()
          get_bV() - get bV[MXTERMS][MXTERMS] array this is solution to:
(package private) static double init_alpha(int j, int k, int nM, double[] xM, double[] yM, double[] wM, double[][] aM)
          init_alpha() - compute parameter alpha(j,k) (EQ.
(package private) static double poly(int k, double x, double y, double[][] aM)
          poly() - compute k'th polynomial function at point (x,y).
 boolean solvePolyXformCoef()
          solvePolyXformCoef() - solve the aU, bV coefficients from LMS data.
 boolean warpLSQ(int nM, double[] xM, double[] yM, double[] zM, double[][] aM, double delta, int xSize, int ySize, double[] sOut)
          warpLSQ() - weighted LSQ spatial transform with orthogonal polynomials Based on algorithm described by Ardeshir Goshtasby in "Image resgistration by local approximation methods", Image and Vision computing, Vold 6, No.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flk

private static Flicker flk
Global instance


lms

private static Landmark lms
landmarks to use


util

private static Util util

MXTERMS

public final int MXTERMS
Maximum number of terms in spatial transform

See Also:
Constant Field Values

nU

int nU
# of CTRL points in x1[], y2[], zU[]


x1

double[] x1
x1 is list of x coordinates for image 1


x2

double[] x2
x2 is list of x coordinates for image 2


z12U

double[] z12U
OUTPUT: z[]= f(x[],y[])


aU

double[][] aU
[MXTERMS][MXTERMS]coefficients


nV

int nV
# of CTRL points in y1[], y2[], zV[]


y1

double[] y1
y1 is list of x coordinates for image 1


y2

double[] y2
y2 is list of x coordinates for image 2


z12V

double[] z12V
OUTPUT: z[]= f(x[],y[])


bV

double[][] bV
[MXTERMS][MXTERMS] coefficients


wM

double[] wM
(dynamic) weights

Constructor Detail

SpatialXform

public SpatialXform(Flicker flk)
SpatialXform() - constructor.

Method Detail

cleanup

public void cleanup()
cleanup() - destroy data structures


solvePolyXformCoef

public boolean solvePolyXformCoef()
solvePolyXformCoef() - solve the aU, bV coefficients from LMS data.

Returns:
true if succeed

get_aU

public final double[][] get_aU()
get_aU() - get aU[MXTERMS][MXTERMS] array this is solution to:
 u=  SUM     SUM    aU_ij * (x**i) * (y**j)
    i=0:n  i=0:n-1

Returns:
aU matrix

get_bV

public final double[][] get_bV()
get_bV() - get bV[MXTERMS][MXTERMS] array this is solution to:
 v=  SUM     SUM    bV_ij * (x**i) * (y**j)
    i=0:n  i=0:n-1

Returns:
bV matrix

evalPoly

public final int evalPoly(int n,
                          int xInt,
                          int yInt,
                          double[][] aM)
evalPoly() - eval f_n(x,y)
 f=  SUM     SUM    c_ij * (x**i) * (y**j)
    i=0:n  i=0:n-1

Parameters:
n - ishighest degree of polynomial
xInt - is point
yInt - is point
aM - is [MXTERMS][MXTERMS] coeffs.
Returns:
value of f_n(x,y)

basis

static final double basis(int f,
                          double x,
                          double y)
basis() - return (x,y) value of f'th orthogonal basis function. pg 75

Parameters:
f - is basis function desired
x - point
y - point
Returns:
(x,y) value of f'th orthogonal basis function

poly

static final double poly(int k,
                         double x,
                         double y,
                         double[][] aM)
poly() - compute k'th polynomial function at point (x,y). pg 74

Parameters:
k - is k'th fct
x - point
y - point
aM - coefficients
Returns:
k'th polynomial function at point (x,y)

coef

static final double coef(int k,
                         int nM,
                         double[] xM,
                         double[] yM,
                         double[] wM,
                         double[] zM,
                         double[][] aM)
coef() - Find kth mapping function coefficient (Eq. 3.6.24) pg 74

Parameters:
k - is kth mapping function
nM - is #CTL pts xM[],yM[],zM[]
xM - list of points
yM - list of points
wM - weights
zM - z[]= f(x[],y[]
aM - coefficients
Returns:
kth mapping function coefficient

init_alpha

static final double init_alpha(int j,
                               int k,
                               int nM,
                               double[] xM,
                               double[] yM,
                               double[] wM,
                               double[][] aM)
init_alpha() - compute parameter alpha(j,k) (EQ. 3.6.23) pg 73

Parameters:
j - index
k - index
nM - is #CTL pts xM[],yM[],zM[]
xM - list of points
yM - list of points
wM - weights
aM - coefficients
Returns:
alpha(j,k)

fitWarpLSQ

public int fitWarpLSQ(int nM,
                      double[] xM,
                      double[] yM,
                      double[] zM,
                      double[][] aM,
                      double delta)
fitWarpLSQ() - weighted LSQ spatial transform w/ orthogonal polynomials Based on algorithm described by Ardeshir Goshtasby in "Image resgistration by local approximation methods", Image and Vision computing, Vold 6, No. 4, 1988. pg 72

Parameters:
nM - is #CTL pts xM[],yM[],zM[]
xM - list of points
yM - list of points
zM - return z[]= f(x[],y[]
aM - coefficients
delta - is smoothing factor, 0 is not smooth
Returns:
the number of terms.

computeSurfaceWarp

public boolean computeSurfaceWarp(int nM,
                                  int terms,
                                  double[] xM,
                                  double[] yM,
                                  double[] zM,
                                  double[][] aM,
                                  double delta,
                                  int xSize,
                                  int ySize,
                                  double[] sOut)
computeSurfaceWarp() - compute surface warp from data.

Parameters:
nM - is # CTRL points xM, yM, zM
terms - is # of terms
xM - points
yM - points
zM - return z[]= f(x[],y[])
aM - coefficients
delta - is smoothing factor, 0 is not smooth
xSize - is size of xM
ySize - is size of yM
sOut - return fitted surface values of points (xSize by ySize).
Returns:
true if succeed

warpLSQ

public boolean warpLSQ(int nM,
                       double[] xM,
                       double[] yM,
                       double[] zM,
                       double[][] aM,
                       double delta,
                       int xSize,
                       int ySize,
                       double[] sOut)
warpLSQ() - weighted LSQ spatial transform with orthogonal polynomials Based on algorithm described by Ardeshir Goshtasby in "Image resgistration by local approximation methods", Image and Vision computing, Vold 6, No. 4, 1988. pg 72

Parameters:
nM - is # CTRL points xM, yM, zM
xM - points
yM - points
zM - return z[]= f(x[],y[])
aM - coefficients
delta - is smoothing factor, 0 is not smooth
xSize - is size of xM
ySize - is size of yM
sOut - return fitted surface values of points (xSize by ySize).
Returns:
true if succeed