bunwarpj
Class BSplineModel

java.lang.Object
  extended by bunwarpj.BSplineModel
All Implemented Interfaces:
java.lang.Runnable

public class BSplineModel
extends java.lang.Object
implements java.lang.Runnable

Class for representing the images and the deformations by cubic B-splines:


Field Summary
private  boolean bSubsampledOutput
          flag for using subsampled output image
private  double[] coefficient
          image spline coefficients
private  boolean coefficientsAreMirrored
          flag to check if the coefficients are mirrored
private  java.util.Stack cpyramid
          stack of coefficients pyramid
private  double[] currentCoefficient
          current image spline coefficients
private  int currentDepth
          current pyramid depth
private  int currentHeight
          current image height
private  double[] currentImage
          current image (at the current resolution level)
private  int currentWidth
          current image width
private  double[] d2xWeight
          x component of the weight of second derivative spline
private  double[] d2yWeight
          y component of the weight of second derivative spline
private  double[] dxWeight
          x component of the weight of derivative spline
private  double[] dyWeight
          y component of the weight of derivative spline
private  boolean fromCurrent
          Interpolation source (current or original)
private  int height
          working image height (after scaling)
private  int heightToUse
          height of the image used for the interpolation
private  double[] image
          working image at maximum resolution (after scaling)
private  java.util.Stack imgpyramid
          stack of image pyramid
private  ij.process.ImageProcessor ip
          image information (after corresponding scaling)
private  boolean isTarget
          flag to check target image
static int MAX_OUTPUT_SIZE
          maximum output window dimensions
private  int maxImageSubsamplingFactor
          sub-sampling factor at highest image resolution level (always a power of 2)
private static int min_image_size
          minimum image size
private  double[] original_image
          original image, full-size without scaling
private  int originalHeight
          original image height (at full-resolution, without scaling)
private  int originalWidth
          original image width (at full-resolution, without scaling)
private  double[][] prec_d2xWeight
          precomputed x component of the weight of second derivative spline
private  double[][] prec_d2yWeight
          precomputed y component of the weight of second derivative spline
private  double[][] prec_dxWeight
          precomputed x component of the weight of derivative spline
private  double[][] prec_dyWeight
          precomputed y component of the weight of derivative spline
 int[][] prec_xIndex
          precomputed x index
private  double[][] prec_xWeight
          precomputed x component of the weight of the spline
 int[][] prec_yIndex
          precomputed y index
private  double[][] prec_yWeight
          precomputed y component of the weight of the spline
private  int pyramidDepth
          resolution pyramid depth
private  int smallestHeight
          smallest image height
private  int smallestWidth
          smallest image width
private  double[] subCoeffs
          subsampled output image B-spline coefficients
private  int subHeight
          height of the subsampled output image
private  double[] subImage
          subsampled output image
private  int subWidth
          width of the subsampled output image
private  java.lang.Thread t
          thread to create the model
private  int width
          working image width (after scaling)
private  int widthToUse
          width of the image used for the interpolation
 int[] xIndex
          x index
private  double[] xWeight
          x component of the weight of the spline
 int[] yIndex
          y index
private  double[] yWeight
          y component of the weight of the spline
 
Constructor Summary
BSplineModel(double[][] c)
          Initialize the model from a set of coefficients.
BSplineModel(double[][] img, boolean isTarget)
          The same as before, but take the image from an array.
BSplineModel(double[] c, int Ydim, int Xdim, int offset)
          Initialize the model from a set of coefficients.
BSplineModel(ij.process.ImageProcessor ip, boolean isTarget, int maxImageSubsamplingFactor)
          Create image model for image processor: image and coefficient pyramid.
 
Method Summary
private  void antiSymmetricFirMirrorOffBounds1D(double[] h, double[] c, double[] s)
           
private  void basicToCardinal2D(double[] basic, double[] cardinal, int width, int height, int degree)
          Pass from basic to cardinal.
private  void buildCoefficientPyramid()
          Build the coefficients pyramid.
private  void buildImagePyramid()
          Build the image pyramid.
private  void cardinalToDual2D(double[] cardinal, double[] dual, int width, int height, int degree)
          Passes from cardinal to dual (2D).
 void clearPyramids()
          Clear the pyramid.
private  void coefficientToGradient1D(double[] c)
          Pass coefficients to gradient (1D).
private  void coefficientToSamples1D(double[] c)
          Pass coefficients to samples.
private  void coefficientToXYGradient2D(double[] basic, double[] xGradient, double[] yGradient, int width, int height)
          Pass coefficients to x,y gradient 2D
private  void dualToCardinal2D(double[] dual, double[] cardinal, int width, int height, int degree)
          Pass from dual to cardinal (2D).
private  void extractColumn(double[] array, int width, int x, double[] column)
          Extract a column from the array.
private  void extractRow(double[] array, int y, double[] row)
          Extract a row from the array .
private  double[] getBasicFromCardinal2D()
          Get basic from cardinal: convert the 2D image from regular samples to standard B-spline coefficients.
private  double[] getBasicFromCardinal2D(double[] cardinal, int width, int height, int degree)
          Get basic from cardinal (2D): convert a 2D signal from regular samples to standard B-spline coefficients.
 double[] getCoefficients()
          Get b-spline coefficients.
 int getCurrentDepth()
          Get current depth.
 int getCurrentHeight()
          Get current height.
 double[] getCurrentImage()
          Get current image.
 int getCurrentWidth()
          Get current width.
 double getFactorHeight()
          Get factor height.
 double getFactorWidth()
          Get fact or width.
private  double[] getHalfDual2D(double[] fullDual, int fullWidth, int fullHeight)
          Get half dual (2D).
 int getHeight()
          Get height.
 double[] getImage()
          Get image (at the maximum resolution size determined by the scaling).
private  double getInitialAntiCausalCoefficientMirrorOffBounds(double[] c, double z, double tolerance)
          Get initial anti-causal coefficients mirror of bounds.
private  double getInitialCausalCoefficientMirrorOffBounds(double[] c, double z, double tolerance)
          Get initial causal coefficients mirror of bounds.
 double[] getOriginalImage()
          Get original image.
 int getOriginalImageHeight()
          Get original image height.
 int getOriginalImageWidth()
          Get original image width.
 double getPixelValFromPyramid(int x, int y)
          Get the pixel value from the image pyramid.
 int getPyramidDepth()
          Get pyramid depth.
 int getSmallestHeight()
          Get smallest height.
 int getSmallestWidth()
          Get smallest width.
(package private)  int getSubHeight()
          Get subsampled output height
 double[] getSubImage()
          Get subsampled output image.
(package private)  int getSubWidth()
          Get subsampled output width
 java.lang.Thread getThread()
          Get thread.
 double getWeightDx(int l, int m)
          Get weight dx.
 double getWeightDxDx(int l, int m)
          Get weight dxdx.
 double getWeightDxDy(int l, int m)
          Get weight dxdy.
 double getWeightDy(int l, int m)
          Get weight dy.
 double getWeightDyDy(int l, int m)
          Get weight dydy.
 double getWeightI(int l, int m)
          Get image coefficient weight.
 int getWidth()
          Get width.
 void interpolateD(double[] D)
          Interpolate the X and Y derivatives of the image at a given point.
 void interpolateD2(double[] D2)
          Interpolate the XY, XX and YY derivatives of the image at a given point.
 double interpolateDx()
          Interpolate the X derivative of the image at a given point.
 double interpolateDxDx()
          Interpolate the X derivative of the image at a given point.
 double interpolateDxDy()
          Interpolate the X derivative of the image at a given point.
 double interpolateDy()
          Interpolate the Y derivative of the image at a given point.
 double interpolateDyDy()
          Interpolate the X derivative of the image at a given point.
 double interpolateI()
          Interpolate the image at a given point.
 boolean isFinest()
          Check if the coefficients pyramid is empty.
(package private)  boolean isSubOutput()
          Get subsampled output flag
 void popFromPyramid()
          Pop one element from the coefficients and image pyramids.
 double precomputed_getWeightDx(int l, int m, int u, int v)
          Get precomputed weight dx.
 double precomputed_getWeightDxDx(int l, int m, int u, int v)
          Get precomputed weight dxdx
 double precomputed_getWeightDxDy(int l, int m, int u, int v)
          Get precomputed weight dxdy
 double precomputed_getWeightDy(int l, int m, int u, int v)
          Get precomputed weight dy
 double precomputed_getWeightDyDy(int l, int m, int u, int v)
          Get precomputed weight dydy
 double precomputed_getWeightI(int l, int m, int u, int v)
          Get precomputed weight of coefficient l,m
 int precomputed_getWidth()
          Get width of precomputed vectors.
 void precomputed_interpolateD(double[] D, int u, int v)
          Interpolate the X and Y derivatives of the image at a given point.
 void precomputed_interpolateD2(double[] D2, int u, int v)
          Interpolate the XY, XX and YY derivatives of the image at a given point.
 double precomputed_interpolateI(int u, int v)
          Interpolate the image (or deformation) at a given point using the precomputed weights.
 void precomputed_prepareForInterpolation(int Ydim, int Xdim, int intervals)
          Prepare precomputations for a given image size.
 void prepareForInterpolation(double x, double y, boolean fromCurrent)
          fromCurrent=true --> The interpolation is prepared to be done from the current image in the pyramid.
 double prepareForInterpolationAndInterpolateI(double x, double y, boolean fromSub, boolean fromCurrent)
          Prepare for interpolation and interpolate fromSub = true --> The interpolation is done from the subsampled version of the image else: fromCurrent=true --> The interpolation is done from the current image in the pyramid.
 double prepareForInterpolationAndInterpolateIAndD(double x, double y, double[] D, boolean fromSub, boolean fromCurrent)
          Prepare for interpolation and interpolate the image value and its derivatives fromSub = true --> The interpolation is done from the subsampled version of the image else: fromCurrent=true --> The interpolation is done from the current image in the pyramid.
private  void putColumn(double[] array, int width, int x, double[] column)
          Put a column in the array.
private  void putRow(double[] array, int y, double[] row)
          Put a row in the array.
 double[] reduceCoeffsBy2(double[] c, int width, int height)
          Reduce coefficients by a factor of 2 (beta)
private  void reduceDual1D(double[] c, double[] s)
          Reduce dual (1D).
 void run()
          Start the image pre-computations.
private  void samplesToInterpolationCoefficient1D(double[] c, int degree, double tolerance)
          Samples to interpolation coefficient (1D).
 void setCoefficients(double[] c, int Ydim, int Xdim, int offset)
          Set spline coefficients.
 void setPyramidDepth(int pyramidDepth)
          Sets the depth up to which the pyramids should be computed.
(package private)  void setSubOutput(boolean b)
          Set subsampled output flag
 void setSubsamplingFactor(int maxImageSubsamplingFactor)
          Set maximum sub-sampling factor
 void startPyramids()
          Start coefficient and image pyramids
private  void symmetricFirMirrorOffBounds1D(double[] h, double[] c, double[] s)
          Symmetric FIR filter with mirror off bounds (1D) conditions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_OUTPUT_SIZE

public static int MAX_OUTPUT_SIZE
maximum output window dimensions


min_image_size

private static int min_image_size
minimum image size


ip

private ij.process.ImageProcessor ip
image information (after corresponding scaling)


t

private java.lang.Thread t
thread to create the model


cpyramid

private final java.util.Stack cpyramid
stack of coefficients pyramid


imgpyramid

private final java.util.Stack imgpyramid
stack of image pyramid


original_image

private double[] original_image
original image, full-size without scaling


image

private double[] image
working image at maximum resolution (after scaling)


coefficient

private double[] coefficient
image spline coefficients


currentImage

private double[] currentImage
current image (at the current resolution level)


currentCoefficient

private double[] currentCoefficient
current image spline coefficients


currentWidth

private int currentWidth
current image width


currentHeight

private int currentHeight
current image height


width

private int width
working image width (after scaling)


height

private int height
working image height (after scaling)


pyramidDepth

private int pyramidDepth
resolution pyramid depth


currentDepth

private int currentDepth
current pyramid depth


smallestWidth

private int smallestWidth
smallest image width


smallestHeight

private int smallestHeight
smallest image height


isTarget

private boolean isTarget
flag to check target image


coefficientsAreMirrored

private boolean coefficientsAreMirrored
flag to check if the coefficients are mirrored


maxImageSubsamplingFactor

private int maxImageSubsamplingFactor
sub-sampling factor at highest image resolution level (always a power of 2)


xIndex

public int[] xIndex
x index


yIndex

public int[] yIndex
y index


xWeight

private double[] xWeight
x component of the weight of the spline


yWeight

private double[] yWeight
y component of the weight of the spline


dxWeight

private double[] dxWeight
x component of the weight of derivative spline


dyWeight

private double[] dyWeight
y component of the weight of derivative spline


d2xWeight

private double[] d2xWeight
x component of the weight of second derivative spline


d2yWeight

private double[] d2yWeight
y component of the weight of second derivative spline


fromCurrent

private boolean fromCurrent
Interpolation source (current or original)


widthToUse

private int widthToUse
width of the image used for the interpolation


heightToUse

private int heightToUse
height of the image used for the interpolation


bSubsampledOutput

private boolean bSubsampledOutput
flag for using subsampled output image


subWidth

private int subWidth
width of the subsampled output image


subHeight

private int subHeight
height of the subsampled output image


subCoeffs

private double[] subCoeffs
subsampled output image B-spline coefficients


subImage

private double[] subImage
subsampled output image


prec_xIndex

public int[][] prec_xIndex
precomputed x index


prec_yIndex

public int[][] prec_yIndex
precomputed y index


prec_xWeight

private double[][] prec_xWeight
precomputed x component of the weight of the spline


prec_yWeight

private double[][] prec_yWeight
precomputed y component of the weight of the spline


prec_dxWeight

private double[][] prec_dxWeight
precomputed x component of the weight of derivative spline


prec_dyWeight

private double[][] prec_dyWeight
precomputed y component of the weight of derivative spline


prec_d2xWeight

private double[][] prec_d2xWeight
precomputed x component of the weight of second derivative spline


prec_d2yWeight

private double[][] prec_d2yWeight
precomputed y component of the weight of second derivative spline


originalWidth

private int originalWidth
original image width (at full-resolution, without scaling)


originalHeight

private int originalHeight
original image height (at full-resolution, without scaling)

Constructor Detail

BSplineModel

public BSplineModel(ij.process.ImageProcessor ip,
                    boolean isTarget,
                    int maxImageSubsamplingFactor)
Create image model for image processor: image and coefficient pyramid. When calling this constructor, the thread is not started, to do so, startPyramids needs to be called.

Parameters:
ip - image in pixel array
isTarget - enables the computation of the derivative or not
maxImageSubsamplingFactor - subsampling factor at highest resolution level

BSplineModel

public BSplineModel(double[][] img,
                    boolean isTarget)
The same as before, but take the image from an array.

Parameters:
img - image in a double array
isTarget - enables the computation of the derivative or not

BSplineModel

public BSplineModel(double[][] c)
Initialize the model from a set of coefficients.

Parameters:
c - Set of B-spline coefficients

BSplineModel

public BSplineModel(double[] c,
                    int Ydim,
                    int Xdim,
                    int offset)
Initialize the model from a set of coefficients. The same as the previous function but now the coefficients are in a single row.

Parameters:
c - Set of B-spline coefficients
Ydim - Y-dimension of the set of coefficients
Xdim - X-dimension of the set of coefficients
offset - Offset of the beginning of the array with respect to the origin of c
Method Detail

startPyramids

public void startPyramids()
Start coefficient and image pyramids


clearPyramids

public void clearPyramids()
Clear the pyramid.


getCurrentHeight

public int getCurrentHeight()
Get current height.

Returns:
the current height of the image/coefficients

getCurrentImage

public double[] getCurrentImage()
Get current image.

Returns:
the current image of the image/coefficients

getCurrentWidth

public int getCurrentWidth()
Get current width.

Returns:
the current width of the image/coefficients

getFactorHeight

public double getFactorHeight()
Get factor height.

Returns:
the relationship between the current size of the image and the original size

getFactorWidth

public double getFactorWidth()
Get fact or width.

Returns:
the relationship between the current size of the image and the original size.

getCurrentDepth

public int getCurrentDepth()
Get current depth.

Returns:
the current depth of the image/coefficients

getHeight

public int getHeight()
Get height.

Returns:
the full-size image height.

getImage

public double[] getImage()
Get image (at the maximum resolution size determined by the scaling).

Returns:
the less scaled image.

getOriginalImage

public double[] getOriginalImage()
Get original image.

Returns:
the original full-size image.

getOriginalImageWidth

public int getOriginalImageWidth()
Get original image width.

Returns:
the original full-size image width.

getOriginalImageHeight

public int getOriginalImageHeight()
Get original image height.

Returns:
the original full-size image height.

getSubImage

public double[] getSubImage()
Get subsampled output image.

Returns:
the subsumpled (to show) output image.

getCoefficients

public double[] getCoefficients()
Get b-spline coefficients.

Returns:
the full-size B-spline coefficients

getPixelValFromPyramid

public double getPixelValFromPyramid(int x,
                                     int y)
Get the pixel value from the image pyramid.

Parameters:
x - x-coordinate of the pixel
y - y-coordinate of the pixel
Returns:
pixel value

getPyramidDepth

public int getPyramidDepth()
Get pyramid depth.

Returns:
the depth of the image pyramid. A depth 1 means that one coarse resolution level is present in the stack. The full-size level is not placed on the stack

getSmallestHeight

public int getSmallestHeight()
Get smallest height.

Returns:
the height of the smallest image in the pyramid

getSmallestWidth

public int getSmallestWidth()
Get smallest width.

Returns:
the width of the smallest image in the pyramid

getThread

public java.lang.Thread getThread()
Get thread.

Returns:
the thread associated

getWidth

public int getWidth()
Get width.

Returns:
the full-size image width

getWeightDx

public double getWeightDx(int l,
                          int m)
Get weight dx.

Returns:
the weight of the coefficient l,m (yWeight, dxWeight) in the image interpolation

getWeightDxDx

public double getWeightDxDx(int l,
                            int m)
Get weight dxdx.

Returns:
the weight of the coefficient l,m (yWeight, d2xWeight) in the image interpolation

getWeightDxDy

public double getWeightDxDy(int l,
                            int m)
Get weight dxdy.

Returns:
the weight of the coefficient l,m (dyWeight, dxWeight) in the image interpolation

getWeightDy

public double getWeightDy(int l,
                          int m)
Get weight dy.

Returns:
the weight of the coefficient l,m (dyWeight, xWeight) in the image interpolation

getWeightDyDy

public double getWeightDyDy(int l,
                            int m)
Get weight dydy.

Returns:
the weight of the coefficient l,m (d2yWeight, xWeight) in the image interpolation

getWeightI

public double getWeightI(int l,
                         int m)
Get image coefficient weight.

Returns:
the weight of the coefficient l,m (yWeight, xWeight) in the image interpolation

interpolateD

public void interpolateD(double[] D)
Interpolate the X and Y derivatives of the image at a given point.

Parameters:
D - output, interpolation the X and Y derivatives of the image

interpolateD2

public void interpolateD2(double[] D2)
Interpolate the XY, XX and YY derivatives of the image at a given point.

Parameters:
D2 - output, interpolation of the XY, XX and YY derivatives of the image

interpolateDx

public double interpolateDx()
Interpolate the X derivative of the image at a given point.

Returns:
dx interpolation

interpolateDxDx

public double interpolateDxDx()
Interpolate the X derivative of the image at a given point.

Returns:
dxdx interpolation

interpolateDxDy

public double interpolateDxDy()
Interpolate the X derivative of the image at a given point.

Returns:
dxdy interpolation

interpolateDy

public double interpolateDy()
Interpolate the Y derivative of the image at a given point.

Returns:
dy interpolation

interpolateDyDy

public double interpolateDyDy()
Interpolate the X derivative of the image at a given point.

Returns:
dydy interpolation

interpolateI

public double interpolateI()
Interpolate the image at a given point.

Returns:
image interpolation

isFinest

public boolean isFinest()
Check if the coefficients pyramid is empty.

Returns:
true when the coefficients pyramid is empty false if not

popFromPyramid

public void popFromPyramid()
Pop one element from the coefficients and image pyramids.


prepareForInterpolation

public void prepareForInterpolation(double x,
                                    double y,
                                    boolean fromCurrent)
fromCurrent=true --> The interpolation is prepared to be done from the current image in the pyramid. fromCurrent=false --> The interpolation is prepared to be done from the original image.

Parameters:
x - x- point coordinate
y - y- point coordinate
fromCurrent - flag to determine the image to do the interpolation from

prepareForInterpolationAndInterpolateI

public double prepareForInterpolationAndInterpolateI(double x,
                                                     double y,
                                                     boolean fromSub,
                                                     boolean fromCurrent)
Prepare for interpolation and interpolate fromSub = true --> The interpolation is done from the subsampled version of the image else: fromCurrent=true --> The interpolation is done from the current image in the pyramid. fromCurrent=false --> The interpolation is done from the original image.

Parameters:
x - x- point coordinate
y - y- point coordinate
fromSub - flat to determine to do the interpolation from the subsampled version of the image
fromCurrent - flag to determine the image to do the interpolation from interpolated value

prepareForInterpolationAndInterpolateIAndD

public double prepareForInterpolationAndInterpolateIAndD(double x,
                                                         double y,
                                                         double[] D,
                                                         boolean fromSub,
                                                         boolean fromCurrent)
Prepare for interpolation and interpolate the image value and its derivatives fromSub = true --> The interpolation is done from the subsampled version of the image else: fromCurrent=true --> The interpolation is done from the current image in the pyramid. fromCurrent=false --> The interpolation is done from the original image.

Parameters:
x - x- point coordinate
y - y- point coordinate
D - output, interpolation the X and Y derivatives of the image
fromSub - flat to determine to do the interpolation from the subsampled version of the image
fromCurrent - flag to determine the image to do the interpolation from interpolated value

precomputed_getWidth

public int precomputed_getWidth()
Get width of precomputed vectors.

Returns:
the width of the precomputed vectors

precomputed_getWeightDx

public double precomputed_getWeightDx(int l,
                                      int m,
                                      int u,
                                      int v)
Get precomputed weight dx.

Parameters:
l -
m -
u -
v -
Returns:
the weight of the coefficient l,m (yIndex, xIndex) in the image interpolation

precomputed_getWeightDxDx

public double precomputed_getWeightDxDx(int l,
                                        int m,
                                        int u,
                                        int v)
Get precomputed weight dxdx

Parameters:
l -
m -
u -
v -
Returns:
the weight of the coefficient l,m (prec_yWeight, prec_d2xWeight) in the image interpolation

precomputed_getWeightDxDy

public double precomputed_getWeightDxDy(int l,
                                        int m,
                                        int u,
                                        int v)
Get precomputed weight dxdy

Parameters:
l -
m -
u -
v -
Returns:
the weight of the coefficient l,m (prec_dyWeight, prec_dxWeight) in the image interpolation

precomputed_getWeightDy

public double precomputed_getWeightDy(int l,
                                      int m,
                                      int u,
                                      int v)
Get precomputed weight dy

Parameters:
l -
m -
u -
v -
Returns:
the weight of the coefficient l,m (prec_dyWeight, prec_xWeight) in the image interpolation

precomputed_getWeightDyDy

public double precomputed_getWeightDyDy(int l,
                                        int m,
                                        int u,
                                        int v)
Get precomputed weight dydy

Parameters:
l -
m -
u -
v -
Returns:
the weight of the coefficient l,m (prec_d2yWeight, prec_xWeight) in the image interpolation

precomputed_getWeightI

public double precomputed_getWeightI(int l,
                                     int m,
                                     int u,
                                     int v)
Get precomputed weight of coefficient l,m

Parameters:
l -
m -
u -
v -
Returns:
the weight of the coefficient l,m (prec_yWeight, prec_xWeight) in the image interpolation

precomputed_interpolateD

public void precomputed_interpolateD(double[] D,
                                     int u,
                                     int v)
Interpolate the X and Y derivatives of the image at a given point.

Parameters:
D - output, X and Y derivatives of the image
u - x- point coordinate
v - y- point coordinate

precomputed_interpolateD2

public void precomputed_interpolateD2(double[] D2,
                                      int u,
                                      int v)
Interpolate the XY, XX and YY derivatives of the image at a given point.

Parameters:
D2 - output, XY, XX and YY derivatives of the image
u - x- point coordinate
v - y- point coordinate

precomputed_interpolateI

public double precomputed_interpolateI(int u,
                                       int v)
Interpolate the image (or deformation) at a given point using the precomputed weights.

Parameters:
u - x- point coordinate
v - y- point coordinate

precomputed_prepareForInterpolation

public void precomputed_prepareForInterpolation(int Ydim,
                                                int Xdim,
                                                int intervals)
Prepare precomputations for a given image size. It calls prepareForInterpolation with ORIGINAL flag.

Parameters:
Ydim - y- image dimension
Xdim - x- image dimension
intervals - intervals in the deformation

run

public void run()
Start the image pre-computations. The computation of the B-spline coefficients of the full-size image is not interruptible; all other methods are.

Specified by:
run in interface java.lang.Runnable

setCoefficients

public void setCoefficients(double[] c,
                            int Ydim,
                            int Xdim,
                            int offset)
Set spline coefficients. Copy coefficients to the model array.

Parameters:
c - Set of B-spline coefficients
Ydim - Y-dimension of the set of coefficients
Xdim - X-dimension of the set of coefficients
offset - Offset of the beginning of the array with respect to the origin of c

setPyramidDepth

public void setPyramidDepth(int pyramidDepth)
Sets the depth up to which the pyramids should be computed.

Parameters:
pyramidDepth - pyramid depth to be set

isSubOutput

boolean isSubOutput()
Get subsampled output flag

Returns:
true if the output needs to be subsampled

setSubOutput

void setSubOutput(boolean b)
Set subsampled output flag

Parameters:
b - new subsampled output flag

getSubHeight

int getSubHeight()
Get subsampled output height

Returns:
subsampled output height

getSubWidth

int getSubWidth()
Get subsampled output width

Returns:
subsampled output width

antiSymmetricFirMirrorOffBounds1D

private void antiSymmetricFirMirrorOffBounds1D(double[] h,
                                               double[] c,
                                               double[] s)
Parameters:
h -
c -
s -

basicToCardinal2D

private void basicToCardinal2D(double[] basic,
                               double[] cardinal,
                               int width,
                               int height,
                               int degree)
Pass from basic to cardinal.

Parameters:
basic - basic (standard B-splines) 2D array
cardinal - cardinal (sampled signal) 2D array
width - 2D signal width
height - 2D signal height
degree - B-splines degree

buildCoefficientPyramid

private void buildCoefficientPyramid()
Build the coefficients pyramid.


buildImagePyramid

private void buildImagePyramid()
Build the image pyramid.


cardinalToDual2D

private void cardinalToDual2D(double[] cardinal,
                              double[] dual,
                              int width,
                              int height,
                              int degree)
Passes from cardinal to dual (2D).

Parameters:
cardinal -
dual -
width -
height -
degree -

coefficientToGradient1D

private void coefficientToGradient1D(double[] c)
Pass coefficients to gradient (1D).

Parameters:
c - coefficients

coefficientToSamples1D

private void coefficientToSamples1D(double[] c)
Pass coefficients to samples.

Parameters:
c - coefficients

coefficientToXYGradient2D

private void coefficientToXYGradient2D(double[] basic,
                                       double[] xGradient,
                                       double[] yGradient,
                                       int width,
                                       int height)
Pass coefficients to x,y gradient 2D

Parameters:
basic -
xGradient -
yGradient -
width -
height -

dualToCardinal2D

private void dualToCardinal2D(double[] dual,
                              double[] cardinal,
                              int width,
                              int height,
                              int degree)
Pass from dual to cardinal (2D).

Parameters:
dual -
cardinal -
width -
height -
degree -

extractColumn

private void extractColumn(double[] array,
                           int width,
                           int x,
                           double[] column)
Extract a column from the array.

Parameters:
array -
width - of the position of the column in the array
x - column position in the array
column - output, extracted column

extractRow

private void extractRow(double[] array,
                        int y,
                        double[] row)
Extract a row from the array .

Parameters:
array -
y - row position in the array
row - output, extracted row

getBasicFromCardinal2D

private double[] getBasicFromCardinal2D()
Get basic from cardinal: convert the 2D image from regular samples to standard B-spline coefficients.

Returns:
array of standard B-spline coefficients

getBasicFromCardinal2D

private double[] getBasicFromCardinal2D(double[] cardinal,
                                        int width,
                                        int height,
                                        int degree)
Get basic from cardinal (2D): convert a 2D signal from regular samples to standard B-spline coefficients.

Parameters:
cardinal - sampled 2D signal
width - signal width
height - signal height
degree - B-spline degree
Returns:
array of standard B-spline coefficients

getHalfDual2D

private double[] getHalfDual2D(double[] fullDual,
                               int fullWidth,
                               int fullHeight)
Get half dual (2D).

Parameters:
fullDual - full coefficients
fullWidth - full coefficients width
fullHeight - full coefficients height

getInitialAntiCausalCoefficientMirrorOffBounds

private double getInitialAntiCausalCoefficientMirrorOffBounds(double[] c,
                                                              double z,
                                                              double tolerance)
Get initial anti-causal coefficients mirror of bounds.

Parameters:
c - coefficients
z -
tolerance -

getInitialCausalCoefficientMirrorOffBounds

private double getInitialCausalCoefficientMirrorOffBounds(double[] c,
                                                          double z,
                                                          double tolerance)
Get initial causal coefficients mirror of bounds.

Parameters:
c - coefficients
z -
tolerance -

putColumn

private void putColumn(double[] array,
                       int width,
                       int x,
                       double[] column)
Put a column in the array.

Parameters:
array -
width - of the position of the column in the array
x - column position in the array
column - column to be put

putRow

private void putRow(double[] array,
                    int y,
                    double[] row)
Put a row in the array.

Parameters:
array -
y - row position in the array
row - row to be put

reduceDual1D

private void reduceDual1D(double[] c,
                          double[] s)
Reduce dual (1D).

Parameters:
c -
s -

samplesToInterpolationCoefficient1D

private void samplesToInterpolationCoefficient1D(double[] c,
                                                 int degree,
                                                 double tolerance)
Samples to interpolation coefficient (1D).

Parameters:
c - coefficients
degree -
tolerance -

symmetricFirMirrorOffBounds1D

private void symmetricFirMirrorOffBounds1D(double[] h,
                                           double[] c,
                                           double[] s)
Symmetric FIR filter with mirror off bounds (1D) conditions.

Parameters:
h -
c -
s -

reduceCoeffsBy2

public double[] reduceCoeffsBy2(double[] c,
                                int width,
                                int height)
Reduce coefficients by a factor of 2 (beta)

Parameters:
c -
width -
height -

setSubsamplingFactor

public void setSubsamplingFactor(int maxImageSubsamplingFactor)
Set maximum sub-sampling factor

Parameters:
maxImageSubsamplingFactor -