Polynomial Transformation Example

Total Page:16

File Type:pdf, Size:1020Kb

Polynomial Transformation Example

B-Splines page 1

B-Spline Transformation

I T B

T

I I B A

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 B- spline 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:

3 B2( t 2) = t 2 6 3 2 B1( t 1) =( -3 t 1 + 3 t 1 + 3 t 1 + 1) 6 3 2 B0( t 0) =(3 t 0 - 6 t 0 + 4) 6 3 B-1( t - 1) =(1 - t - 1 ) 6

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

t2=( x +16) 8; t 1 =( x + 8) 8; t 0 = 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 (u) f( x) = B( x -( x0 + iu)) 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 (u) f( x) = ci B( x -( x0 + iu)) i

Error: Reference source not found 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. , 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 Error: Reference source not found 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 4. 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:

nx, n y , n z (ux) (uy ) ( u z ) f( x, y , z) = cijk B( x - iu x) B( y - ju y) B( z - ku z ) i, j , k where we have used nx, n y , n z and ux , uy , 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. , one each to represent the x, y, and z coordinates:

nx, n y , n z (x) ( ux) (uy ) ( u z ) x( x, y , z) = cijk B( x - iu x) B( y - ju y) B( z - ku z ) i, j , k

nx, n y , n z ( y) ( ux) (uy ) ( u z ) y( x, y , z) = cijk B( x - iu x) B( y - ju y) B( z - ku z ) i, j , k

nx, n y , n z (z) ( ux) (uy ) ( u z ) z( x, y , z) = cijk B( x - iu x) B( y - ju y) B( z - ku z ) i, j , k

These three equations may be combined into one by defining a three element vector of ( x) ( y) ( z) coefficients for each i,j,k: cijk= (c ijk, c ijk , c ijk ) :

nx, n y , n z (ux) (uy ) ( u z ) r( r,{ cijk }) = c ijkB( x - iu x) B( y - ju y) B( z - ku z ) i, j , k

where rⅱ= (x, y ⅱ , z ) , r = (x, y , z) , and {cijk } is the set of 3 nx n y n z 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, and

nx, n y , n z (ux) (uy ) ( u z ) d( r,{ cijk }) = c ijkB( x - iu x) B( y - ju y) B( z - ku 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 {cijk }min that minimizes

C( IA(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 one- eighth 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

{cijk } . 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 may sometimes produce warpings that are overly drastic for a given application. The B-Splines page 8 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 + l C 2

where C1 is the similarity term, C2 is the regularization term, and l 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 dx 犏dx dy dz 犏 犏dyⅱ dy dy J = . 犏dx dy dz 犏 犏dzⅱ dz dz 犏 臌dx dy dz

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

2 C2 =(det( J ) - 1) 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

Recommended publications