0% found this document useful (0 votes)
87 views44 pages

ANA Projects List

Here are the steps to numerically optimize the parameters of a controller using Berzier curves: 1. Define the Berzier curve equation with parameter t that defines the path. This will have control points that need to be optimized. 2. Define the cost function that evaluates the error between the Berzier curve path and the desired guidance corridor. This cost should incorporate errors in position as well as smoothness. 3. Initialize the control point parameters randomly. 4. Numerically optimize the parameters using a gradient-based method like gradient descent. At each iteration: - Calculate the cost function value for the current parameters - Compute the gradient of the cost function with respect to the parameters - Update the parameters in the

Uploaded by

Raul Garcia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views44 pages

ANA Projects List

Here are the steps to numerically optimize the parameters of a controller using Berzier curves: 1. Define the Berzier curve equation with parameter t that defines the path. This will have control points that need to be optimized. 2. Define the cost function that evaluates the error between the Berzier curve path and the desired guidance corridor. This cost should incorporate errors in position as well as smoothness. 3. Initialize the control point parameters randomly. 4. Numerically optimize the parameters using a gradient-based method like gradient descent. At each iteration: - Calculate the cost function value for the current parameters - Compute the gradient of the cost function with respect to the parameters - Update the parameters in the

Uploaded by

Raul Garcia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

ANA Projects Set 3

Cubic Spline Interpolation (CSI)


Points (knots) -> Interpolation -> fitting

Spline: A numeric function that is defined in a piecewise manner


• multiple weighted polynomial functions
• smoother transition at knots
• as good as interpolating with high degree polynomials
• immune to instability
Problem Description
Generate a 3D structure when you know portion of it projected in 2D and
the 3D coordinates of an ensemble of knots (points)

Assume
a known 3D tubular structure, the prototype structure P(x,y,z)
The ability to get:
1 or 2 projections Pr(J, R, x, y, z) of this shape where J =1 or 2 and R is the plane
of the projection
N knots, i.e. Points in space {K(I, x, y, z)} where I = 1, 2, … N

Generate a model of the structure using the Pr(J, R) and the ensemble {K(I, x, y, z)}
-Cubic Spline interpolation function SF(x,y,z)
-Knots {K} and points on the projection Pr(J, R)

Calculate the error SF(x,y,z) vs P(x,y,z)


CSI-1
Find the orientation of the projection plane that optimizes interpolation assuming
that you have
1 projection Pr(1, R, x, y, z) and 1 point K(1, x, y, z)
1 projection Pr(1, R, x, y, z) and 2 points K(1, x, y, z), K(2, x, y, z)
1 projection Pr(1, R, x, y, z) and 3 points K(1, x, y, z), K(2, x, y, z) and K(3, x, y, z)

there are certain boundary conditions imposed by


•The Pr(J, R, x, y, z) and {K(I, x, y, z)}
•The length of the structure!!!!
P(x,y,z)

K(1, x, y, z)

Pr(1, R, x, y, z)

X
CSI-2
In this case, assume that you have an ensemble of points (K(J, x, y, z)) and you
know the projection of a segment of the the projection i.e. NOT the projection of the
entire length! Then

Find the minimum number of (K(J, x, y, z)) knots that are needed to generate the
original structure for different known segments

Generate a “moving window” on the structure and use the transient 2D projection of
this window and 3D knots to generate the structure
Length of moving Window (independent of shape)
Number of knots
Length of P(x,y,z)

Moving
window
P(x,y,z)
Interpolation Issues: Runge
This family of project will deal with Runge phenomenon that pertains to the
interpolation of equally spaced points and the errors secondary to this type of
distribution.
This is a very imporant phenomenon with consequences in sampling real data!
• Analyze the reasons for this phenomenon
• Relate to the Gibbs phenomenon (and Gibbs artifacts)
• Then, compare the equally spaced to Chebyshev points
Runge Phenomenon (Oscillations)
1 9th order
5th order polynomial
9th order 1  25x 2

● What is practically a good


polynomial order?
Compressed/Sparse Sampling

“sensing … as a way Sparsity prior


of extracting
information about an Generalized sampling

object from a small


number of randomly Stability

selected observations”
Candès et. al. Reconstruction
Investigate the for an
appropriate data set,
compressed sensing has the
capability to perform a
"random" sub-Nyquist
sampling and still recover the
image to a large extent
without noticeable visual
artifacts.
floating-point arithmetic
Start with the very famous paper by David Goldberg “what every computer scientist
should know about floating-point arithmetic (1991)

Study the discussion of the IEEE standard (IEEE 754), and the analysis on the
floating-point arithmetic.
Fourrier Analysis
Implement Fourier analysis code on
PC
Smart-phone,

Use this code to analyze your voice


Processing Images
We will focus on numerical computing methods in deblurring images.

Start stadying the material Per Christian’s website:


http://www.imm.dtu.dk/~pcha/HNO/

Select some area of interest

At this page are listed some of the areas


SVD Analysis and TSVD Solutions; Boundary Conditions. This challenge uses the
m-file P2Acode.m.
Regularization and Perturbation Errors.
Color Image Deblurring. This challenge uses the MATLAB function array3mult.m.
Deblurring of an Astronomical Image. The image used here is dfsc6215.png.
Deblurring of the Antarctic Penguins Image. This challenge uses the mat-file
penguins.mat.
Salt-and-Pepper Noise.
Wavelets and their applications.
The MathworksTM Wavelet Toolbox provides a good introduction to the powerf
tool of wavelets, mathematical functions that allow data to be analyzed at wide
different scales. Material from Gil Strang’s MIT course on wavelets (18.327) is
available through MIT OpenCourseware (Google “MIT OCW”). Wavelets are
related to Fourier analysis, the subject of project 9.
7.
Applications of linear algebra.
Linear algebra plays an important role in biomolecular modeling, one of the many
areas in modern computational biology. The paper “Linear algebra in biomolecular
modeling”, by Zhijun Wu (2006),
orion.math.iastate.edu/wu/modeling06.pdf
discusses several of the main applications of linear algebra. (This paper is a chapter
in Handbook of Linear Algebra, mentioned in project 2). A key idea is that “off
the shelf” techniques such as Gaussian elimination need to be adapted to take
advantage of the special structure of the biology problems.
Non Uniform Fast Fourier Transform
Theme: implement and study FFT algorithms for non-uniform distribution of sampled points
Effector Controller
Theme: Numerically calculate the output of a controller code based on specific drive strategy
Input: Velocity, Position, Velocity setpoint, Position setpoint, previous state of the controller, object size
Output: gradients, gradient specs (value, slew rate), new state of the controller
Variables: Controller parameters
Provided by Instructor: the Equations that describe the drive laws

Code specifics:

Input:
1. Current Velocity and position
2. Path and Velocity profile

Output:
1. The generated setpoint
2. The calculated 3D Drive Function Grad_X(j), Grad_Y(j), Grad_Z(i)
3. Report and graph the specifics of the 3D Drive function: (1) first derivative, (2) second derivative along
each axis and the total vector
4. Errors

Controller architecture:

Equations:

BD=constant, 1025 Kg/m3

Notes:
 The position setpoint is generated by searching the point of the path that is closest to the actual
position.
 The velocity setpoint Vc is the corresponding point on the velocity profile.

The code should save three files:


1. Study report: a text file that has the
2. j, Grad_X(j), Grad_Y(j), Grad_Z(j)
3. j, Ph_X(j), Ph_Y(j), Ph_Z(j), Vc_X(j), Vc_Y(j), Vc_Z(j), Grad_X(j), Grad_Y(j), Grad_Z(j), dGrad_X(j),
dGrad_Y(j), dGrad_Z(i), d2Grad_X(j), d2Grad_Y(j), d2Grad_Z(i)
Function Response
Theme: Numerically simulate the trajectory of an object based on specific input function and calculate
relevant trajectory data.
Input: gradients, GC, trajectory, velocity law
Output: actual path, errors,
variables: object size
Provided by Instructor: Equations that describe the drive laws

Code specifics:
A GUI that shows
Input:
1. A 3D Input function G= [Gx, Gy, Gz](j) NOTE: These are the gradients results
2. The GC
3. Size of effector scalar NOTE: magnetic properties and size of the MRBot
4. Motion Profile (an array V(j)) NOTE: Velocity Profile at each location
5. Environment Profile (an array F(j)) NOTE: The environmental forces profile at each location
6. Color based indicator of the distance from CG (Green everything is fine, red we are too slose
to the GC.

Output:
1. The responses of the 3D Input Function, Actual path of the MRbot and actual velocity profile
PhResp(j) ( = [X, Y, Z](j)) NOTE: This is the modeled path
2. The planned trajectory (path and velocity profile)
5. Errors of PhResp(j) vs PhTarget(j) for different MC/NC: MC = NC, MC = nNC n<1

Equations:
 Newton’s second law
 with M: magnetization of the sphere at saturation = 1.274e6 A/m for
iron
 Cd=0.47 for a sphere
Response Man-in-the-Loop
Theme: Time domain visualization of object
Provided by Instructor: the inputs
Code specifics:
The GUI that shows in time domain in three windows (i) Object inside 3D corridor, (ii) transient
position of object in a cut through and (iii) current position on a 3D path
Input:
1. A target function, a vector PhTarget(j) ( = [X, Y, Z](j)) NOTE: This is our path
2. An executed function, a vector PhActual(j) ( = [X, Y, Z](j))
3. A 3D tubular structure InCG(j)
4. Time relationship of index and Dt
5. Smoothing degree SmD scalar
6. Size of object (OBJ) scalar

Output:
1. Smoothed 3D tubular structure (SmVG(j))
2. Error SmVG(j) vs InCG(j)
3. Out1: 3D scene with SmVG(j), PhTarget(j), PhActual(j), OBJ; based on Dt actuate it
4. Out 2: transient 2D orthogonal cut to the PhTarget(j), that shows the SmVG(j), PhTarget(j),
PhActual(j), OBJ
5. Out 3: 3D scene with PhTarget(j), PhActual(j) and OBJ as a sphere
6. Errors
Optimization of a Drive Function
Theme: Numerically Optimize the parameters of a controller. There will be 3 projects given based on:
1. Berzier Curves
2. Corridor Maps
3. Simulated Annealing
4. Splines-based

Provided by Instructor:
1) A 3D guidance corridor (VG; in STL format)
2) the cost function equation

Code specifics:
 The GUI must show the progress of the optimization during its computation (current point, best
point, number of iterations).
 The initial path to start optimziaiton will be the centerline of the 3D VG

Input:
1. The 3D virtual corridor (VG)
2. Desired path and velocity profile boundaries

Output:
1. Optimum controller parameters
2. Max errors, average error, min distance from VC, average distance from VG
3. Max gradient, max slew rate.
2D AND 3D Gradient and Directional Derivatives

Theme: Learn to extract derivatives and gradients of multidimensional functions, and compare them.
Specifically, numerically calculate the directional derivative of a function A and compare it to another function
B.
Teams: There are two versions of the project: a 2D for 1 student team and 3D for 2- to 3- student teams. There
are other combinations of teams, contact the instructor
Description: Function A in 3D is a function A(x. y, z). First implement the code to calculate the partial
derivatives along the three axes (directional derivation) dA/dx, dA/dy and dA/dz. Then calculate the vector
dA/dr (r is the unit vector along axis X, Y, Z).
Algorithm Input: function A(x,y)/A(x,y,z), B(x,y)/B(x,y,z), comapriason
Algorithm Output: the derivatives of A(x,y)/A(x,y,z), comparison of the value of derivatives of A(x,y)/A(x,y,z) vs
B(x,y)/B(x,y,z) on each axis, comparison of the vector of derivatives A(x,y)/A(x,y,z) vs the vector defined by the
B(x,y)/B(x,y,z) function
Provided by the instructor: A(x,y)/A(x,y,z), B(x,y)/B(x,y,z).

Figure below shows an example of how the vectors of the directional derivatives are shown and relate to the
function of the ellipses 4x^2+y^2=c, where c is a constant
Generation of 3D or 4D Corridors

Theme: Implement a numerical approach for 3D segmentation method and generation of rendered 3D and 4D
corridors. The segmentation will be based on the Region-Growing algorithm and renderings on meshing.
Interpolation will be needed at higher resolution than images requiring careful interpolation so the mesh is
concervative in nature and does not collide or cross any structure.
Algorithm Input: Data D(x,y,z), Criterion C(i), Initialization I(x,y,z), k connectivity
Provided by the instructor: Pseudo algorithm of the desired method, Data D(x,y,z), various Criteria C(i),
Initialization I(x,y,z,j) and their associated Ground truth GT(x,y,z,i,j,k)

Name Explanation Data type/Description


D 3D data matrix n x m x k matrix
C Criterion Input function
I Initialization: 3D binary matrix n x m x k matrix
k Connectivity parameter scalar
R Result: 3D binary matrix n x m x k matrix
GT Ground truth: 3D binary matrix n x m x k matrix

Data(x,y,z)

C(i)
PrX R(x,y,z,i,j,k)
I(x,y,z,j)

Figure 1: Overview of the code input/output. The output will be compared to GT to test the
correctness of the algorithm
Operator Selected Parameters & calculations:
1. 3D matrix: Input data D and initialization region I.
2. Function: Criterion C to apply to grow I using the data D. The function takes as input a set of value and
returns an interval of inclusion.
3. Scalar: k represents the connectivity of the morphological space and can have 3 values in 3D:
 6: the voxels are considered neighbors if they have one face in common.
 18: the voxels are neighbors if they have at least an edge in common.
 26: the voxels are neighbors if they have at least a vertex in common.
Algorithm Output: The algorithm outputs the final stage R of the growing process as a binary 3D matrix, where
the Boolean represents the inclusion or not in the result. This result will be compared to the given ground truth
to ensure the process correctness
Algorithms: 3D morphological operations using a customable inclusion criterion
Algorithm pseudo-code:
 Let R0 be the initial region, i.e. I.
 While Rt is different than Rt-1 do:
o Let t+1 be the current step.
o Let V be the set of value of the voxels in Rt: V = {D(x,y,z) | Rt(x,y,z) is true}.
o Let A be the interval resulting of the call C(V).
o Let Rt+1 = Rt .
o For each k-connected neighbors (x,y,z) of the voxels in Rt, if D(x,y,z) is included in A, then
add (x,y,z) to Rt+1.
 Return R, the last iteration of Rt.
Software Output: The software returns a region of k-connected region resulting the growth of an initial region I,
using an inclusion criterion C.

Figure 2: The input will be slices that have a gap between them. After segmentation the segmententation maps
will be used to fit a 3D mesh as shown in (A) and (B)

Studies:
Your code will be tested with two data sets provided by the instructor:
1. one will be a CINE MRI set of the beating heart (N slices each capturing the heart motion in M time
frames). Thus you will use your algorithm to segment NxM 2D slices. These will then be used to
generate a 4D of the segmentation map and a 4D mesh
2. the other will be a set of brain images that will eb sued to extract the vessels and a tumor generating a
3D segmentation map and 3D mesh
All data will be in DICOM and form the headers you can find their position in 3D space
Spline Interpolation and Error Estimation

Theme: implement and study Spline Interpolation of points in 3D

There are several options

See following pages

See a report on splines


You can use this as a starting point for your work
Function Filters

Theme: implement and study algorithms for processing digital images

Study the included paper and implement Frangi filter

The Original work of Frangi Filter is this:


http://www.tecn.upf.es/~afrangi/articles/miccai1998.pdf
Magnetic Field Generated by Coils
Theme: Calculate the field produced by assemblies of solenoid coils.
Provided by Instructor: Description of the calculation method

Code specifics:
A GUI that shows Current Distributions, field, flux density and cut through projections on X, Y, Z.
Graphics tool allows interactively adjusting the distribution of the currents

Input:
1. The number of solenoids, their position and orientation
2. Size of the coils Size(j)
3. Cut through Size of distribution (rectangular) LX(J), Lz(J)

Output:
1. The field H (Hx, Hy, Hz)(i) and flux density B (Bx, By, Bz)(i)
2. Isosurfaces for an operator requested B value
1. Volume (as isosurfaces) with operator requested gradient (in ppm of Bcenter)

Notes on the Modelization of the Magnetic Field


Notations: H is the magnetic field (A/m), B is the flux density (T).
1. Flux density produced by a single current loop in all space:

According to [1], the flux density produced by a circular current loop in all space is:

K(x) and E(x) are the complete elliptic integral of the first and second kind respectively.
[1]: Simple Analytic Expressions for the Magnetic Field of a Circular Current Loop, James Simpson, John
Lane, Christopher Immer, and Robert Youngquist, 2001.
Matlab implementation:
This function has been implemented into matlab.
[ B ] = Field_single_loop( M,I,a )

B: returned result. Vector containing each component of the magnetic flux density in the cylindrical coordinate
system [Br,Bθ,Bz], value are in Tesla.
M: Vector containing the coordinates of the calculation point in the cylindrical coordinate system. Values are in
meters.
A: radius of the current loop (meters)
I: current in the loop (in amps).

Magnetic flux density produced by a single cylindrical coil in all space:

The cylindrical coil is discretized into currents loop. The magnetic field is calculated by summing the field
produced by each current loop. The previous function is used to calculate the flux density produced by the
current loops.

The flux density Bij produced by the current loop i,j at the calculation point M(Rm, θm, Zm) is:

Where Zj is the Z coordinate of the considered current loop:

And ai is the radius of the considered current loop:


The total flux density at the point M is the vectorial sum of the flux density produced by each current loop:

Matlab implementation:
This function has been implemented into matlab:
[ B ] = Field_single_coil(M,Re,Ri,T,Itot )
B: returned result. Vector containing each component of the magnetic flux density in the cylindrical coordinate
system [Br,Bθ,Bz], value are in Tesla.
M: Vector containing the coordinates of the calculation point in the cylindrical coordinate system. Values are in
meters.
Re: External radius of the coil in meters.
Ri: Internal radius of the coil in meters.
T: thickness of the coil in meters.
Itot: Total current inside the coil, in amps. It is equal to the current in the electric wire multiplied by the number
of turns.
Study the following so you see how we treat 2 solenoids; your project will be for any arbitrary number of
coils
3/ Magnetic flux density produced by two cylindrical coils in all space
The field produced by two coils is calculated by summing the flux density produced by each coil. The two coils
axis are collinear to the z axis of the cylindrical coordinate system. The center of the coils are separated by d.

The flux density B produced by the two coils at the calculation point M(Rm, θm, Zm) is:

B = Field_single_coil( ,Re,Ri,T,Itot1 )+ Field_single_coil( ,Re,Ri,T,Itot2 )

Matlab Implementation
This function has been implemented into matlab.
[ B ] = Field_two_coils( M,Re,Ri,T,d,Itot1,Itot2 )
B: returned result. Vector containing each component of the magnetic flux density in the cylindrical coordinate
system [Br,Bθ,Bz], value are in Tesla.
M: Vector containing the coordinates of the calculation point in the cylindrical coordinate system. Values are in
meters.
Re: External radius of the coil in meters.
Ri: Internal radius of the coil in meters.
T: thickness of the coil in meters.
d: distance between the center of the coils
Itot1: Total current inside the coil #1, in amps. It is equal to the current in the electric wire multiplied by the
number of turns.
Itot2: Total current inside the coil #2, in amps. It is equal to the current in the electric wire multiplied by the
number of turns.
Spline Interpolation and Error Estimation

Theme: implement and study Spline Interpolation of points in 3D

There are several options

See following pages

See a report on splines


You can use this as a starting point for your work
Contents
1 Introduction 3
2 Process 4
3 B-Spline Interpolation 4
3.1. Knot Vector Generation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
3.2. Deboor’s Algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
4 Sampling Points 6
4.1. Left – Skewed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
4.2. Right – Skewed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
4.3. Uniformly – Distributed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
5 Error Estimation 6
6 Tools 7
7 Algorithm 7
8 Experiments and Results 8
8.1. Capturing Input Data Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
8.1.1. Manual Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 8
8.1.2. GUI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . 9
8.2. Testing with various Input Data Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
8.2.1. Input Data 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . .10
8.2.2. Input Data 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . .11
8.2.3. Input Data 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . .12
8.3. Observations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
9 Challenges 14
10 Conclusions 14
11 References 14

2|Page
1 Introduction
Interpolation
In most of the scientific applications we only know a limited number of data which
represent the values of a function for a limited number of values of the independent
variable. So whenever we want to know the values at some unknown points we always
need to estimate the values of the function for some intermediate values of the
independent variable. This can be achieved using Curve fitting.
This can be done using various methods like
1. Piecewise constant interpolation
2. Linear interpolation
3. Polynomial interpolation
4. Spline interpolation.
B-Spline Interpolation
B-Splines find their applications in the construction of Rail Road Tracks, ships and
flights etc. In flight modeling and production, splines can be used to represent
machine tool cutter paths, engineering analysis and simulation, navigation and
guidance systems. For instance, we consider the navigation systems, the entire path of
the flight needs to be generated from a given set of locations (which can be considered
as “Control Points”) on the globe. Given the source and destination locations, we need
to generate a smooth plan that passes through the first and last control points, which
is where we bring the B-Splines into the scenario. The objective of this project is to
generate a smooth spline using the given set of control points.
Advantages of choosing this method over the other methods
B-Spline interpolation is very useful when compared to other parametric curves
because in case of other curves the order of the curve is fixed based on the number of
control points so as the number of control points increases the order of the curve
increases which makes it complicated to perform calculations. B-Spline curves
overcome this disadvantage.
For example if we are taking 4 control points then the degree of the polynomial that
we need to solve would be 4 and as we increase the number of control points this
degree increases making it more complicated. But using B-Spline curves we can even
control the degree of the polynomial that need to be generated.

3|Page
Moreover B-Spline curves also has the advantage of local propagation unlike global
propagation of other methods. In other interpolation methods as it is a global
propagation if there is a change in a single control point the shape of the complete
interpolant changes but in the case of B-Spline even though there is a change in a
single control point it only changes the segments which are related to this control point
and all other segments are not affected.

2 Process
The major steps involved in the Spline Fitting and Error Estimation are as mentioned
below:
1. Generating the Knot vector
2. Implementing the Deboor's Algorithm for B-Spline Interpolation
3. Sampling the points, to test the B-Spline Interpolation
4. Estimating the error between the original and test splines

Approach
The spline fitting involves capturing the user input which are referred to as Control
points Pi, then generating the Knot Vector t based on the order, k of the piecewise
segment of the B-Spline and the number of points, n. The knot vector is then used to
interpolate the user input by solving the Deboor’s recurrence formula r. The output
of the interpolation gives a set of points (which we term as “Ground truth”) stretched
between the first point and the last point, which are smoothed by the control points.
The order k determines how many control points effect each segment in the B-Spline.
By default, we have taken the value of k to be 3, since it solves global propagation
problem compared to other interpolation methods and maintains curvature
continuity, meaning that two curves joining at a point they go in the same direction
where they meet and also have same radius at that point and also slope continuity,
meaning that the two curves not only touch, but they do even go in the same direction
at the point where they touch.

3 B-Spline Interpolation
Given a set of points and the order of the segment, the first and last points control
only one segment within the B-Spline. Remaining points control the segments
depending upon the value of k.
4|Page
3.1 Knot Vector Generation
Once we obtain the n+1 control points P0, P1, P2,……, Pn and degree k, we can generate
a knot vector. For a B-Spline curve of degree k, we need m+1 knots where m=n+k+1.
Precisely, the first k knots are 0’s and the remaining knots would be in an incrementing
order till the (m-k)th knot and the last k knots will have the same value.
0 𝑖𝑓 𝑖 ≤ 𝑘
𝑡𝑖 = { 𝑖 − 𝑘 𝑖𝑓 𝑘 ≤ 𝑖 ≤ 𝑛
𝑛−𝑘+2 𝑖𝑓 𝑖 > 𝑛

3.2 Deboor’s Algorithm


B-Spline can be simply defined as a composite curve which consists of various number
of curves. The degree of a B-Spline curve can be independent of the number of
control points. B-Splines maintain local control, hence any change in one of the
control points doesn’t change the entire curve but only the segments which depend
upon that particular control point. While there are many spline interpolation
techniques, we have used the Deboor’s algorithm for fitting the spline. According to
the algorithm, a B-Spline curve can be defined as a linear combination of control
points Pi and B-Spline basis functions Ni,k(t) given by:
𝑛

𝑟(𝑡) = ∑ 𝑝𝑖 𝑁𝑖,𝑘 (𝑡), 𝑛 ≥ 𝑘 − 1, 𝑡 𝜖[𝑡𝑘−1 , 𝑡𝑛+1 ]


𝑖=0

Where k is the order of each of the piecewise polynomial segments that form the B-
Spline curve. A polynomial of degree 3 solves the problem of slope continuity and
curvature continuity, hence in our project we choose the k value to be 3. A polynomial
degree above 3, doesn’t have any signification change. The basis function for the B-
Spline is defined by the Knot-Sequence t. The basis function for a polynomial segment
of the order of k can be defined as below:

1, 𝑖𝑓 𝑡 𝜖 [𝑡𝑖 , 𝑡𝑖+1 ),
𝑁𝑖,1 (𝑡) = {
0, 𝑂𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
and if k > 1,
5|Page
𝑡 − 𝑡𝑖 𝑡𝑖+𝑘 − 𝑡
𝑁𝑖,𝑘 (𝑡) = ( ) 𝑁𝑖,𝑘−1 (𝑡) + ( )𝑁 (𝑡)
𝑡𝑖+𝑘−1 − 𝑡𝑖 𝑡𝑖+𝑘 − 𝑡𝑖+1 𝑖+1,𝑘−1

Where t defines the Knot vector. By solving the equation r(t),we generate the data
points Di which form the spline and are controlled by the control points Pi.

4 Sampling Points
After generating the “Ground Truth” i.e., the data points Di, we do sampling to
select n control points to generate a new spline. These new set of control points will
be referred to as Si. We have used three different samples to analyze the
performance of the interpolation method we have implemented:
4.1 Left-Skewed: Choosing the control points such that, more points towards
the beginning of the curve and fewer points towards the ending of the curve.
4.2 Right-Skewed: Choosing the control points such that, fewer points towards
the beginning of the curve and more points towards the ending of the curve.
4.3 Uniformly-Distributed: Choosing the control points such that they are
uniformly distributed from the beginning to the ending of the curve.

5 Error Estimation
Once we have the test set of control points Si, we interpolate the sample using the knot
vector and deboor’s algorithm for spline interpolation. The interpolated points are
then plotted. The plot clearly shows the deviation of the test samples from the
“Ground Truth”. We then calculate the average error distance between the original
and the test sample curves. We have used Euclidean distance between each of the
points. The average of the sum of all the distances gives the amount of deviation. We
calculate the error using the below mentioned formula:

𝑑𝑖𝑠𝑡((𝑥1 , 𝑦1 , 𝑧1 ), (𝑥2 , 𝑦2 , 𝑧2 )) = √(𝑥1 − 𝑥2 )2 + (𝑦1 − 𝑦2 )2 + (𝑧1 − 𝑧2 )2

Average of the Error distance:


𝑑𝑖𝑠𝑡((𝑥1 ,𝑦1 ,𝑧1 ),(𝑥2 ,𝑦2 ,𝑧2 ))
,
𝑛

6|Page
Where n is the number of points in “Ground Truth” Di.

6 Tools
We have implemented the project in MATLAB. It provides a variety of tool bars
which enable for a better GUI and proper plotting in 3-D Co-ordinate system.

7 Algorithm
The spline fitting and error-estimation consists of the following steps:
i. Input a set of ‘n’ points and order ‘k’ for the piecewise polynomial
ii. Calculate the Knot Vector
iii. Generate the piecewise polynomial equation for each of the segments
between two control points using Deboor’s algorithm
iv. Generate the spline from the output set of points from spline
interpolation
v. Select a set of points from the spline satisfying the following three
conditions:
o Points sparse towards the beginning of the spline curve
o Points sparse towards the end of the spline curve
o Points equally distributed throughout the spline
vi. Interpolate the BSpline
vii. Estimate the error

7|Page
Block Diagram:

Points
Knot Vector B-Spline Sampling Error
User Input
Generation Interpolation and Estimation
Interpolation

8 Experiments and Results


8.1 Capturing Input Data Points
Our implementation provides with two options to enter the input points:
 Manual
 GUI

Fig 1: Choosing the method of input

8.1.1 Manual Input


For manual input of points we display a textbox to insert the co-ordinates by
separating with commas. Ex: 1.45, 2.35, 3.45

8|Page
Fig 2: Manual method of input

8.1.2 GUI
For selecting the input points through GUI, we first display an empty X-Y axis and
select the x, y co-ordinates. Then in another plot we display the Y-Z axis and restrict
the selection of z, to only the corresponding y, z co-ordinates where y is from the
previous selection. Once you select a point in Y-Z plot, user should press enter to
confirm the selection. The below images show the two axes which are used for the
selection of x, y and z co-ordinates:

Fig 3: Capturing the x, y co-ordinates

9|Page
Fig 4: Capturing the y, z co-ordinates

8.2 Testing the method with various Data Points


We have tested the Spline interpolation with various points and estimated the error
generated for three data samples. Given below are various datasets and the
corresponding spline plots.

8.2.1 Input Data 1


X 6.01 18.58 15.64 42.11 65.90 68.85
Y 36.62 25.65 15.27 19.66 17.61 10.89
Z 15.47 18.35 32.07 41.32 40.37 48.35

The output obtained by interpolating the above points is shown in the figure below:

10 | P a g e
Fig 5: Plot of the original spline and Sample Test Splines

The above image displays the original alpine and the test splines generated from
sampling the “Ground Truth”. The top-right corner of the image displays various
line formats used for each of the splines and also the corresponding average error
distance for the Left-Skewed, Right-Skewed and Uniformly Distributed samples.

8.2.2 Input Data 2


X 6.81 17.78 36.22 40.50 60.56 96.65
Y 20.24 31.50 24.92 11.76 31.06 29.60
Z 2.2447 3.67 6.32 3.244 7.39 14.09

The output obtained by interpolating the above points is shown in the figure below:

11 | P a g e
Fig 6: Plot of the original spline and Sample Test Splines

The above image displays the original alpine and the test splines generated from
sampling the “Ground Truth”. The top-right corner of the image displays various
line formats used for each of the splines and also the corresponding average error
distance for the Left-Skewed, Right-Skewed and Uniformly Distributed samples.

8.2.3 Input Data 3


X 18.85 27.40 47.727 65.64 91.31 120.187
Y 27.41 17.90 34.137 34.42 15.277 30.92
Z 6.428 5.769 11.923 14.011 18.73 18.406

The output obtained by interpolating the above points is shown in the figure below:

12 | P a g e
Fig 7: Plot of the original spline and Sample Test Splines

The above image displays the original alpine and the test splines generated from
sampling the “Ground Truth”. The top-right corner of the image displays various
line formats used for each of the splines and also the corresponding average error
distance for the Left-Skewed, Right-Skewed and Uniformly Distributed samples.
8.3 Observations
From the above tests the following observations have been made regarding the
average error distance:
Dataset 1 Dataset 2 Dataset 3
Left-Skewed 13.7511 9.76 13.7193
Right-Skewed 16.5237 22.015 28.057
Uniformly-Distributed 8.2181 5.8713 7.607

The above table displays the corresponding average error distances calculated for the
test samples, generated from each of the datasets. From the above table, following
observations can be made:
 The average error distance is less for the uniformly-distributed test sample in
all of the datasets.
 The average error distance for left-skewed and right-skewed test samples
doesn’t follow any specific trend.
13 | P a g e
9 Challenges
Initially when we started with getting input from the user using a GUI we faced
issue with getting a 3D input from the user because so we finally decided with
getting the 3D input in two 2D planes like XY plane and YZ plane. For this
first we are asking user to select a point from the XY plane and once he
selects a point as we know the Y coordinates, in the YZ plane we are
restricting the user to this Y value and asking him to select some Z value.

10 Conclusions
From the above experimentations we can conclude that the number of points
and the distribution of these points affects the shape of the B-Spline
generated.

11 References
https://www.wikiwand.com/en/Interpolation
https://www.wikiwand.com/en/B-spline
http://www.geos.ed.ac.uk/~yliu23/docs/lect_spline.pdf
http://scholar.lib.vt.edu/theses/available/etd-04192001-172731/unrestricted/chapter_4.pdf

14 | P a g e
Appendix
Steps to execute the program:
i. Install MatLab version R2014a
ii. Load all the files in the FinalCode folder into MatLab
iii. Open the file start.m and click run
iv. Select the mode of input and capture the data points
v. The results will be displayed

15 | P a g e

You might also like