[Insight-users] about the number of the control points of the Cubic BSpline

Luis Ibanez luis.ibanez at kitware.com
Tue Jul 20 00:19:28 EDT 2004


Hi Yixun,

In theory you are right,
but in practice you are wrong   :-)

------------------------------------------

PLEASE MAKE SURE THAT YOU READ THIS EMAIL USING FIXED SIZE FONTS,
OTHERWISE THE DIAGRAMS WILL ALL BE DISTORTED.


When you use Cubic BSplines in 1D in order to interpolate
a value at one point you need the closest 4 grid nodes of
the spline.

If you have grid nodes in positions 0,1,2,3,4,5
and you interpolate a point at position 2.1 you will
need the values from positions { 1, 2, 3,4 }.

               2.1
                |
        *     * |   *     *
  |     |     | V   |     |     |
  +-----+-----+-+---+-----+-----+
  0     1     2     3     4     5


If you want to interpolate the value at 2.00001
you will need the values at grid points { 1, 2, 3,4 }.


              2.0001
               |
        *     *|    *     *
  |     |     |V    |     |     |
  +-----+-----++----+-----+-----+
  0     1     2     3     4     5




If you want to interpolate the value at 1.999999
you will need the values at grid points { 0, 1, 2, 3 }.


          1.99999
             |
  *     *    |*     *
  |     |    V|     |     |     |
  +-----+----++-----+-----+-----+
  0     1     2     3     4     5


If you want to interpolate at 2.0 it is a matter of
*choice* it you make it depend on {0,1,2,3} or {1,2,3,4}
although the choice is a bit pointless since in both cases
the weight of contributions from node 0 and node 4 will
be equal to zero, and the weights of nodes 1, 2 will not
change depending on our selection of intervals.


The *choice* made in the ITK BSpline transform has been
to make 1.0 depend on {0,1,2,3}, the consequence of this
choice is that an integer position "i" depends on

    {  i-1,  i, i+1 , i+2 }

when you apply this condition to the first pixel of the
image, you note that you need ONE BSpline grid point
*before* the first pixel.

When you apply the condition to the last pixel of the
image, you note that you need TWO BSpline grid points
*after* the last pixel.

>From the mathematical point of view you can certainly argue
that you cat get away with removing that last i+2 grid point
since you are in the limit of the value and after all the
contribution weight from the spline will be zero.

However...

In the Evil world of Computer Programming, the mathematical
laws of limits, continuity and infinite series are superseded
by the infallible laws of Murphy's misfortune  :-)

Murphy's laws clearly state:

   If there is a single, remote and unlikely chance that
   your program may access an element of an array past
   its allocated size...        then it will !!.



The addition of this extra i+2 element to the BSpline grid
is the safeguard against the fatalistic mandate of Murphy's
laws. This extra grid node prevents us from accidentally
attempting to access a node of the BSpline outside the grid.

Of course you could have prevented this too by adding an
extra checking on the coordinates of the point to be
interpolated, and if you find that it is at the end of the
image you could manage carefully that special case.
That option would make you pay for an extra "if" *every*
time you evaluate the interpolate a value on the BSpline
grid.

With the addition of the i+2 node, we can simply use the
same expression for interpolating a pixel regardless of
its position in the image.



Regards,



   Luis


-----------------
Yixun Liu wrote:

>  
> Hi ITKUsers,
>  
> I do not fully understand the meaning of the following sentences about 
>  the number of the control points of BSpline.
>  
> //  Since we are using a BSpline of order 3, the coverage of the BSpling 
> grid
> //  should exceed by one the spatial extent of the image on the lower 
> region of
> //  image indices, and by two grid points on the upper region of image 
> indices.
>  
> In my opinion, if the internal grid can just cover the full image, we 
> only need exceed by one grid instead of two on the upper region of image 
> indices.
>  
> Hope your confirmation!
>  
> Regards,
>  
> Yixun Liu
>  
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users





More information about the Insight-users mailing list