Polynomial Transformation Example

advertisement
B-Splines
page 1
B-Spline Transformation
IBT
T
IB
IA
As for polynomial and thin-plate-spline transformations, T goes from the transformed
image back to the untransformed image, again because it is difficult to find the inverse.
Splines
In common usage, the word “spline” means any shape that smoothly passes through a set
of points. Thus, it is a smooth interpolating function. As we did for the polynomial
transformations and for the thin-plate splines, we will consider such a set of points to be
the x’ coordinates, or the y’ coordinates, or the z’ coordinates in the transformation in the
figure above, and each fitting is treated as a separate problem. Thus, at a small set of
points x,y,z in the space of image IA, we specify a value for x’. Then we use a spline to
interpolate those points. We repeat that process for y’ and for z’. Then we use the values
of the x spline to specify x’ at other points in IA, and use the y spline for y’ and the z’
spline for z’. This simplifies the problem one of a mapping from 3D space to 3D space
into a three mappings from 3D space into 1D space.
While we use the term “spline” in “thin-plate splines”, mathematicians reserve the word
spline for functions based on polynomials. The B-splines are a common set of functions
used to specify splines.
1D splines
It is easy to understand 2D and 3D B-splines as combinations of 1D splines. So we start
with 1D.
The most important feature of a spline is that it is a function that is non-zero over only a
small region of space. That region is divided into a set of sub regions, and the B-spline is
equal to a polynomial over each sub region. An example of a one-dimensional spline
B  x  is shown in Figure 1:
B-Splines
page 2
Figure 1. Cubic B-Spline.
The vertical dashed lines separate the plot into four regions, and the curve in each region
is a polynomial. Each of these four polynomials is cubic, and as a result, this spline is
called a “cubic B-spline”. (“B-spline is short for “basis spline”.) The points at which the
pieces join are called “knots”, and that term may refer to the positions on the function
given by the black circles or to the x values, where the vertical dashed lines intersect the
horizontal axis.
The four pieces meet so smoothly that it may seem as if the entire spline is one
polynomial. That this is not true can be seen by extending each polynomial beyond the
knots as shown in Figure 2.
Figure 2. Cubic B-Sline, showing pieces extended beyond the
knots.
B-Splines
page 3
The cubic-spline is the most common form of spline based on polynomials used in
medical image registration. We will treat it exclusively, but once it is understood, all
other degrees of spline can be understood at the same level.
The four polynomial pieces in Figure 1 meet at the same value so that the resulting spline
is continuous across each knot. In addition, as can be see in Figure 2, the slopes are the
same. As a result the first derivative is continuous across each knot. While it is not as
clear from the figure, the second derivatives are also equal at the knots, so the cubic Bspline is continuous and has continuous 1st, and 2nd derivatives.
While continuity is not absolutely necessary for digital imaging, it insures that functions
based on these splines will not make sudden changes that will result in warpings for
which there is a tear or a kink.
As can be guessed from the figure above, this B-spline is nonzero only between -16 and +
16. (These numbers happen to be powers of two, and powers of two are common because
of computational simplifications, but they are not required.) Outside this range it equals
zero everywhere and thus all derivatives are zero outside the range as well. At these two
ends, the value of the spline and its first and second derivatives reach zero. Thus, the
spline is continuous and has continuous 1st and 2nd derivatives everywhere. It can be
shown mathematically however, that, if a function f  x  is nonzero over only a finite
range of x, then it must have discontinuous derivatives of some order. This spline is no
exception. At its ends all its derivatives are zero with one exception: Its third derivative is
non-zero.
To specify a cubic B-spline, we specify the distance u between knots. The spline then
spans a distance of 4u. In the example above u = 8, so the spline spans a distance of 32.
Between each pair of knots we define a parameter t that goes from 0 at the left knot to 1
at the right knot within the pair. We then define four separate polynomials in t:
B2  t2   t23 6
B1  t1    3t13  3t12  3t1  1 6
B0  t0    3t03  6t02  4  6
(1)
B1  t1   1  t1  6
3
The polynomials always have exactly these forms for the cubic B-spline, but the relation
of the parameters to x depends on the width and position of the B-spline. For this
example
(2)
t2   x  16 8; t1   x  8 8; t0  x 8; t1   x  8 8
B-Splines
page 4
(The strange use of indices in decreasing size and ending at –1 results in some
computational simplification. See Chapter 8, Eqs (8.15) and (8.16). Other enumerations
are used by other authors. It is of no particular consequence here.)
Making a function from B-splines
Now that we know how to make B  x  , we can use it to make a function. That is done by
adding several splines together. In most cases the splines are all of the same width, so the
only difference between them is their relative positions along the x axis. Their position is
determined by a shift from the position shown in Figure 1, and the shift is always by an
integral multiple of the distance u between knots. Figure 3 shows the result of adding
five copies of the spline in Figure 1. The result approaches a square function.
Figure 3. Sum of five shifted cubic B-splines
Mathematically this particular summation looks like this:
5
f  x    B u   x   x0  iu  
(3)
i
where x0 = 16 and u = 8, and we have added the superscript (u) to B to specify the knot
spacing that defines the shape of the spline. The general form includes coefficients that
weight the splines differently, including negative weights:
n
f  x    ci B  u   x   x0  iu  
(4)
i
Figure 4 gives an example, in which there are 10 splines of width 64, and their
weightings are from left to are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. Thus, in Eq. (4), ci = 1, x0 = 8,
and u = 16.
B-Splines
page 5
Figure 4. Weighted sum of shifted cubic B-splines
Localization of changes
The limited nonzero range of each B-spline in the sum results in a localization of
changes. If, for example, the 7th coefficient in the weighted sum used in Figure 4 is
changed to –3, there is a drastic change in those regions to which the 7th B-spline is
nonzero, but outside those regions there is no effect whatever, as can be seen by
Figure 5. Demonstration of the localization of changes
B-Splines
page 6
comparing the two figures in those regions to the left and right of the spline visible below
the x axis. It should also be noted that the region that is changed by changing the
coefficient for a given B-spline equals the region of support of the spline—its nonzero
region. It is desired to make only very local changes, meaning changes over only very
small regions, then splines with small support should be used. If it is desired to make
more global changes, meaning changes over larger regions, then splines with large
support should be used. We will learn that in the typical registration algorithm employing
B-splines iterative approaches are used in which the first iterations involve B-splines with
large support, with the support size decreasing with each successive iteration.
3D splines
The extension of 1D to 2D or 3D is extremely easy. The 3D cubic spline is simply the
product of three 1D splines and the coefficients have three subscripts:
f  x, y , z  
n x ,n y ,n z

u
cijk B ux   x  iu x B  y   y  ju y  B uz   z  ku z 
(5)
i , j ,k
where we have used n x , n y , n z and ux , u y , and uz to indicate that the number of splines
and their knot spacing can be different in the, x, y, and z directions, respectively. We have
omitted the shift x0 because it is typically set to zero.
For geometrical transformations we will have three versions of Eq. (5), one each to
represent the x, y, and z coordinates:
x  x, y , z  
n x ,n y ,n z

c
x
ijk
B
ux 
 x  iux B u   y  ju y  B u   z  kuz 
y
z
i , j ,k
y   x, y , z  
n x ,n y ,n z
u
c  y ijk B ux   x  iu x B  y   y  ju y  B uz   z  ku z 

(6)
i , j ,k
z  x, y , z  
n x ,n y ,n z

c
z
ijk
B
ux 
 x  iux B u   y  ju y  B u   z  kuz 
y
z
i , j ,k
These three equations may be combined into one by defining a three element vector of
 x  y z
, cijk , cijk :
coefficients for each i,j,k: cijk  cijk

r  r,{cijk } 
n x ,n y ,n z


u
c ijk B ux   x  iux B  y   y  ju y  B uz   z  kuz 
(7)
i , j ,k
where r   x, y, z , r   x, y, z  , and {c ijk } is the set of 3 nx n y nz coefficients.
Alternatively, , if the transformation is expected to be close to the identity, then instead of
using these summations to express r  , they may be used instead to express the
displacement, d = r  – r , from the original position to the warped point. In that case
B-Splines
page 7
r  = r + d,
(8)
and
d  r,{c ijk } 
n x ,n y ,n z

c ijk B 
ux 
 x  iux B u   y  ju y  B u   z  kuz  .
y
z
i , j ,k
Use in Image Registration
It is possible to use these splines to fit a transformation to a given set of point
transformations, as we did with the polynomial transformations and the thin-plate
transformations, but that is not in fact how these splines are typically used in image
registration. Instead, they are typically used not in point-based registration but in
intensity-based registration, in which a similarity function based on intensity patterns, as
for example mutual information, the sum of absolute intensity differences, or any of the
many such functions that we have studied, is maximized or a cost function, which may be
simply the negative of a similarity function, is minimized. If we let C represent the cost
function, then we search for a set of coefficients {c ijk }min that minimizes



C I A r  , I B r r,{cijk } .
This is a complex nonlinear optimization problem typically involving hundreds or even
thousands of degrees of freedom. Common approaches to this large problem include
starting with a small number of B-splines spread over the image, each with a large region
of support and finding a transformation. As mentioned above these “large” splines
produce global changes. After that a larger number of smaller B-splines, say, eight times
as many (a factor of two each in the x, y, and z directions) with a region of support oneeighth the size is used to handle more local changes. This procedure continues for several
steps with the spline size decreasing with each step often by a factor of two in each
dimension for computational convenience. This progressive increase in the “resolution”
of the B-spline array may be accompanied by an increase in the resolution of the image as
well. At the beginning, when global changes are made, a low resolution version of the
two images might be used in order to reduce the time necessary to calculate the cost
function. As the resolution of the B-spline array increases, the resolution of the images
used in the cost function increases as well, until at the last step the original images are
used at full resolution.
At each step it is necessary to perform a minimization of C by varying the coefficients
{c ijk } . There are many heuristic methods for such minimizations including gird search,
steepest descent, Powel’s method, and stochastic methods such as simulated annealing
and genetic algorithms. Numerical Recipes is an excellent reference.
Regularization
Any transformation may exhibit unacceptable spatial behavior. We have seen drastic
examples with polynomial transformations, but even the relatively well behaved B-spline
B-Splines
page 8
may sometimes produce warpings that are overly drastic for a given application. The
standard approach for controlling spatial behavior is regularization. Regularization in this
context is simply biasing the search for a solution toward more spatially smooth
transformations. When a cost function such as one based on image intensity patterns is
being minimized, it is easy to perform regularization by adding a term that is large when
some less desirable aspect of the warping is large.
Then we have
C  C1  C2
(9)
where C1 is the similarity term, C2 is the regularization term, and  is an adjustable
parameter. A commonly used regularization term is a sum of squared second derivatives,
such as, for example, that given in Eq. (3) of Thin-Plate Splines.doc (with the integral
changed to a sum over all voxels). Another commonly used term involves the
determinant of the Jacobian of the transformation,
 dx
 dx

 dy 
J 
dx

 dz 
 dx

dx
dy
dy 
dy
dz 
dy
dx 
dz 

dy  
.
dz 

dz  
dz 
(10)
The determinant of the Jacobian equals 1 at a point if and only if there is no stretching or
compression in the region around the point. Therefore, the following regularization term
C2   det  J   1
2
(11)
penalizes warpings in which there is stretching or compression. (Instead of squaring the
difference, the absolute value may be used as well. A physical model in which this term
is always zero is an incompressible liquid (water is an excellent approximation). Liquid
motion is highly nonrigid, but its Jacobian is always equal to one. Since much of the
body behaves like an incompressible fluid, this regularization makes physical sense.
The choice of the form of both C1 and C2 is difficult to justify a priori. They are typically
justified in terms of the results of some measure or measures of the efficacy of the
registrations in a set of experiments used to validate the entire procedure. In the end the
combination of warping function, cost function, and minimization method is usually
judged experimentally as a whole, and there is rarely only one combination that works.
There is a good deal of art that goes with the science of nonrigid registration.
B-Splines
page 9
Download