Package gov.nih.mipav.model.algorithms
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
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.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final doubleprivate intDOCUMENT ME!private intDOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private double[]DOCUMENT ME!private intDOCUMENT ME!private double[][][]private static double[][]Blending matrix for a 4th degree Bspline.private intDOCUMENT ME!private intDOCUMENT ME!private intDOCUMENT ME!Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublebSpline2D(int orderDx, int orderDy, double x, double y) This method is out of date, as it provides smoothed interpolation as opposed to precise interpolation.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.doublebSpline3D(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.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.floatbSplineJet1D(byte derivOrder, float t, float[] dataX) This method can also be used to calculate derivatives of the Bspline.WildMagic.LibFoundation.Mathematics.Vector2fbSplineJetXY(int derivOrder, float t, float[] dataX, float[] dataY) This method can also be used to calculate derivatives of the Bspline.WildMagic.LibFoundation.Mathematics.Vector3fbSplineJetXYZ(int derivOrder, float t, float[] dataX, float[] dataY, float[] dataZ) This method can also be used to calculate derivatives of the Bspline.javax.vecmath.Vector3dbSplineJetXYZ_double(int derivOrder, float t, float[] dataX, float[] dataY, float[] dataZ) This method can also be used to calculate derivatives of the Bspline.private voidConvertToInterpolationCoefficients(double[] c, int DataLength, double[] z, int NbPoles, double Tolerance) voidfinalize()Clean up memeory.private double[]GetColumn(int x, int z, double[][][] Image) private double[]GetRow(int y, int z, double[][][] Image, int width) private double[]GetVertical(int x, int y, double[][][] Image) private doubleInitialAntiCausalCoefficient(double[] c, int DataLength, double z) private doubleInitialCausalCoefficient(double[] c, int DataLength, double z, double Tolerance) private doubleinterpolateBSpline(double[][][] image, double x, double y, double z, int SplineDegree) Do the B-Spline Interpolationprivate doubleinterpolateBSpline2D(double[][][] image, double x, double y, int SplineDegree) private voidPutColumn(double[] Line, int x, int z, double[][][] Image) private voidPutRow(double[] Line, int y, int z, double[][][] Image) private voidPutVertical(double[] Line, int x, int y, double[][][] Image) voidResets parameters used by the Bsplines.voidDefault method that is not really appropriate for this class but must be defined because this class extends AlgorithmBase.private intSamplesToCoefficients(double[][][] Image, int SplineDegree) private intSamplesToCoefficients2D(double[][][] Image, int SplineDegree) voidsetup2DBSpline(double[] vol, int[] extents, int _degree) Allocates memory and constructs arrays needed for BSpline.voidsetup2DBSplineC(double[] vol, int[] extents, int _degree) Allocates memory and constructs arrays needed for BSpline.voidsetup3DBSpline(double[] vol, int[] extents, int _degree) setup3DBSpline - setup 3D Bspline for black and white.voidsetup3DBSplineC(double[] vol, int[] extents, int _degree) Allocates memory and constructs arrays needed for BSpline.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, windowOpenedMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
mat4
private static double[][] mat4Blending matrix for a 4th degree Bspline. -
DBL_EPSILON
private final double DBL_EPSILON- See Also:
-
degree
private int degreeDOCUMENT ME! -
dt
private double[] dtDOCUMENT ME! -
dt_double
private double[] dt_doubleDOCUMENT ME! -
geoms
private double[] geomsDOCUMENT ME! -
geomx
private double[] geomxDOCUMENT ME! -
geomy
private double[] geomyDOCUMENT ME! -
geomz
private double[] geomzDOCUMENT ME! -
width
private int widthDOCUMENT ME! -
height
private int heightDOCUMENT ME! -
depth
private int depthDOCUMENT ME! -
xold_tbase
private int xold_tbaseDOCUMENT ME! -
xyold_tbase
private int xyold_tbaseDOCUMENT 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 interesty- 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 interesty- 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 interesty- double point index along the Bspline indicating point of interestz- 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 interesty- double point index along the Bspline indicating point of interestz- 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 interestdataX- 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 interestdataX- control points for the BsplinedataY- 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 interestdataX- control points for the BsplinedataY- control points for the BsplinedataZ- 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 interestdataX- control points for the BsplinedataY- control points for the BsplinedataZ- control points for the Bspline- Returns:
- the Bspline interpolated data point
-
finalize
public void finalize()Clean up memeory.- Overrides:
finalizein classAlgorithmBase
-
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:
runAlgorithmin classAlgorithmBase
-
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 Bsplineextents- 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 Bsplineextents- 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 Bsplineextents- 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 Bsplineextents- 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 interpolatey- y coordinate where to interpolatez- z coordinate where to interpolateSplineDegree- Degree of the B-SplineBcoeff- B-spline array of coefficientsWidth- Width of the imageHeight- Height of the imageDepth- 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- SamplesDataLength- Number of samples or coefficientsz- PolesNbPoles- Number of polesTolerance- 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)
-