Class AlgorithmBSpline

java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.AlgorithmBSpline
All Implemented Interfaces:
ActionListener, WindowListener, Runnable, EventListener

public class AlgorithmBSpline extends AlgorithmBase
Modified code from Aaron Carass's Java implementation of Philippe Thevenaz's Cubic B-spline Interpolation. Code is simply wrapped to allow for calls consistent with MIPAV style as well as allow for 2D images. B-Spline interpolation.
Author:
Philippe Thevenaz, Aaron Carass Jet code is untouched from when the new code was implemented on June 24th, 2014. Fourth-order Bspline for 1-3D lines and 2D surface. This class is based on code from Dave Eberly's MAGIC C++ library.
  • Field Details

    • mat4

      private static double[][] mat4
      Blending matrix for a 4th degree Bspline.
    • DBL_EPSILON

      private final double DBL_EPSILON
      See Also:
    • degree

      private int degree
      DOCUMENT ME!
    • dt

      private double[] dt
      DOCUMENT ME!
    • dt_double

      private double[] dt_double
      DOCUMENT ME!
    • geoms

      private double[] geoms
      DOCUMENT ME!
    • geomx

      private double[] geomx
      DOCUMENT ME!
    • geomy

      private double[] geomy
      DOCUMENT ME!
    • geomz

      private double[] geomz
      DOCUMENT ME!
    • width

      private int width
      DOCUMENT ME!
    • height

      private int height
      DOCUMENT ME!
    • depth

      private int depth
      DOCUMENT ME!
    • xold_tbase

      private int xold_tbase
      DOCUMENT ME!
    • xyold_tbase

      private int xyold_tbase
      DOCUMENT ME!
    • colorInter

    • imData

      private double[][][] imData
  • Constructor Details

    • AlgorithmBSpline

      public AlgorithmBSpline()
      default constructor.
  • Method Details

    • bSpline2D

      public double bSpline2D(int orderDx, int orderDy, double x, double y)
      This method is out of date, as it provides smoothed interpolation as opposed to precise interpolation. For precise interpolation, use the analogous method in AlgorithmBSpline3D instead, as that provides true B-spline interpolation. This method can also be used to calculate derivatives of the Bspline.
      Parameters:
      orderDx - derivative order in x direction (n invalid input: '<'= 4 )
      orderDy - derivative order in y direction (n invalid input: '<'= 4 )
      x - double point index along the Bspline indicating point of interest
      y - double point index along the Bspline indicating point of interest
      Returns:
      the Bspline interpolated data point
    • bSpline2DC

      public double[] bSpline2DC(int orderDx, int orderDy, double x, double y)
      This method is out of date, as it provides smoothed interpolation as opposed to precise interpolation. For precise interpolation, use the analogous method in AlgorithmBSpline3D instead, as that provides true B-spline interpolation. This method can also be used to calculate derivatives of the Bspline.
      Parameters:
      orderDx - derivative order in x direction (n invalid input: '<'= 4 )
      orderDy - derivative order in y direction (n invalid input: '<'= 4 )
      x - double point index along the Bspline indicating point of interest
      y - double point index along the Bspline indicating point of interest
      Returns:
      the Bspline interpolated data point
    • bSpline3D

      public double bSpline3D(int orderDx, int orderDy, int orderDz, double x, double y, double z)
      This method is out of date, as it provides smoothed interpolation as opposed to precise interpolation. For precise interpolation, use the analogous method in AlgorithmBSpline3D instead, as that provides true B-spline interpolation. 3D graph Bspline for black and white. This method can also be used to calculate derivatives of the Bspline. WARNING - programmer must call setup3DBSpline before using this function!!!
      Parameters:
      orderDx - derivative order in x direction (n invalid input: '<'= 4 )
      orderDy - derivative order in y direction (n invalid input: '<'= 4 )
      orderDz - derivative order in z direction (n invalid input: '<'= 4 )
      x - double point index along the Bspline indicating point of interest
      y - double point index along the Bspline indicating point of interest
      z - double point index along the Bspline indicating pointof interest
      Returns:
      the Bspline interpolated data point
    • bSpline3DC

      public double[] bSpline3DC(int orderDx, int orderDy, int orderDz, double x, double y, double z)
      This method is out of date, as it provides smoothed interpolation as opposed to precise interpolation. For precise interpolation, use the analogous method in AlgorithmBSpline3D instead, as that provides true B-spline interpolation. 3D graph Bspline for color. This method can also be used to calculate derivatives of the Bspline. WARNING - programmer must call setup3DBSpline before using this function!!!
      Parameters:
      orderDx - derivative order in x direction (n invalid input: '<'= 4 )
      orderDy - derivative order in y direction (n invalid input: '<'= 4 )
      orderDz - derivative order in z direction (n invalid input: '<'= 4 )
      x - double point index along the Bspline indicating point of interest
      y - double point index along the Bspline indicating point of interest
      z - double point index along the Bspline indicating point of interest
      Returns:
      the Bspline interpolated data point
    • bSplineJet1D

      public float bSplineJet1D(byte derivOrder, float t, float[] dataX)
      This method can also be used to calculate derivatives of the Bspline.
      Parameters:
      derivOrder - derivative order (n invalid input: '<'= 4 )
      t - float point index along the Bspline indicating point of interest
      dataX - control points for the Bspline
      Returns:
      the Bspline interpolated data point
    • bSplineJetXY

      public WildMagic.LibFoundation.Mathematics.Vector2f bSplineJetXY(int derivOrder, float t, float[] dataX, float[] dataY)
      This method can also be used to calculate derivatives of the Bspline. Used for smoothing VOI lines
      Parameters:
      derivOrder - derivative order (n invalid input: '<'= 4 )
      t - float point index along the Bspline indicating point of interest
      dataX - control points for the Bspline
      dataY - control points for the Bspline
      Returns:
      the Bspline interpolated data point
    • bSplineJetXYZ

      public WildMagic.LibFoundation.Mathematics.Vector3f bSplineJetXYZ(int derivOrder, float t, float[] dataX, float[] dataY, float[] dataZ)
      This method can also be used to calculate derivatives of the Bspline. Used for smoothing VOI lines
      Parameters:
      derivOrder - derivative order (n invalid input: '<'= 4 )
      t - float point index along the Bspline indicating point of interest
      dataX - control points for the Bspline
      dataY - control points for the Bspline
      dataZ - control points for the Bspline
      Returns:
      the Bspline interpolated data point
    • bSplineJetXYZ_double

      public javax.vecmath.Vector3d bSplineJetXYZ_double(int derivOrder, float t, float[] dataX, float[] dataY, float[] dataZ)
      This method can also be used to calculate derivatives of the Bspline.
      Parameters:
      derivOrder - derivative order (n invalid input: '<'= 4 )
      t - float point index along the Bspline indicating point of interest
      dataX - control points for the Bspline
      dataY - control points for the Bspline
      dataZ - control points for the Bspline
      Returns:
      the Bspline interpolated data point
    • finalize

      public void finalize()
      Clean up memeory.
      Overrides:
      finalize in class AlgorithmBase
    • resetBspline

      public void resetBspline()
      Resets parameters used by the Bsplines.
    • runAlgorithm

      public void runAlgorithm()
      Default method that is not really appropriate for this class but must be defined because this class extends AlgorithmBase.
      Specified by:
      runAlgorithm in class AlgorithmBase
    • setup2DBSpline

      public void setup2DBSpline(double[] vol, int[] extents, int _degree)
      Allocates memory and constructs arrays needed for BSpline.
      Parameters:
      vol - volume comprising control points for the Bspline
      extents - vol extents (xDim,yDim)
      _degree - degree of spline (3 or 4)
    • setup2DBSplineC

      public void setup2DBSplineC(double[] vol, int[] extents, int _degree)
      Allocates memory and constructs arrays needed for BSpline.
      Parameters:
      vol - volume comprising control points for the Bspline
      extents - vol extents (xDim,yDim)
      _degree - degree of spline (3 or 4)
    • setup3DBSpline

      public void setup3DBSpline(double[] vol, int[] extents, int _degree)
      setup3DBSpline - setup 3D Bspline for black and white. Allocates memory and constructs arrays needed for BSpline
      Parameters:
      vol - volume comprising control points for the Bspline
      extents - vol extents (xDim,yDim, zDim)
      _degree - degree of spline (3 or 4)
    • setup3DBSplineC

      public void setup3DBSplineC(double[] vol, int[] extents, int _degree)
      Allocates memory and constructs arrays needed for BSpline.
      Parameters:
      vol - volume comprising control points for the Bspline
      extents - vol extents (xDim,yDim, zDim)
      _degree - degree of spline (3 or 4)
    • interpolateBSpline

      private double interpolateBSpline(double[][][] image, double x, double y, double z, int SplineDegree)
      Do the B-Spline Interpolation
      Parameters:
      x - x coordinate where to interpolate
      y - y coordinate where to interpolate
      z - z coordinate where to interpolate
      SplineDegree - Degree of the B-Spline
      Bcoeff - B-spline array of coefficients
      Width - Width of the image
      Height - Height of the image
      Depth - Depth of the image
    • interpolateBSpline2D

      private double interpolateBSpline2D(double[][][] image, double x, double y, int SplineDegree)
    • ConvertToInterpolationCoefficients

      private void ConvertToInterpolationCoefficients(double[] c, int DataLength, double[] z, int NbPoles, double Tolerance)
      Parameters:
      c - Samples
      DataLength - Number of samples or coefficients
      z - Poles
      NbPoles - Number of poles
      Tolerance - Admissible relative error
    • InitialCausalCoefficient

      private double InitialCausalCoefficient(double[] c, int DataLength, double z, double Tolerance)
    • InitialAntiCausalCoefficient

      private double InitialAntiCausalCoefficient(double[] c, int DataLength, double z)
    • GetRow

      private double[] GetRow(int y, int z, double[][][] Image, int width)
    • PutRow

      private void PutRow(double[] Line, int y, int z, double[][][] Image)
    • GetColumn

      private double[] GetColumn(int x, int z, double[][][] Image)
    • PutColumn

      private void PutColumn(double[] Line, int x, int z, double[][][] Image)
    • GetVertical

      private double[] GetVertical(int x, int y, double[][][] Image)
    • PutVertical

      private void PutVertical(double[] Line, int x, int y, double[][][] Image)
    • SamplesToCoefficients

      private int SamplesToCoefficients(double[][][] Image, int SplineDegree)
    • SamplesToCoefficients2D

      private int SamplesToCoefficients2D(double[][][] Image, int SplineDegree)