B-spline Grid, Image and Point based Registration (original) (raw)
B-spline registration of two 2D / 3D images or corrsp. points, affine and with smooth b-spline grid.
33.1K Downloads
Updated16 Mar 2011
Affine and B-spline grid based registration and data-fitting of two 2D color/grayscale images or 3D volumes or point-data. Registration can be done intensity / pixel based, or landmark / corresponding points based (See OpenSurf), or a combination.
Description Pixel-based registration:
This function is an (enhanced) implementation of the b-spline registration algorithm in D. Rueckert et al. "Nonrigid Registration Using Free-Form Deformations: Application to Breast MR Images". Including the smoothness penalty of Rueckert (thin sheet of metal bending energy), and Jacobian (diffeomorphic) function. Also including, localized normalized mutual information as registration error, allowing the images or volumes to be of a different type/modality for instance a MRI T1 and T2 patient scan.
How it works:
A grid of b-spline control points is constructed which controls the transformation of an input image. An error measure is used to measure the registration error between the moving and static image. The quasi newton Matlab optimizer fminlbfgs (also on Mathworks) is used to move the control points to achieve the optimal registration between both images with minimal registration error.
Usage:
- The function image_registration.m is easy to use, and contains examples in the help, and will fit most applications. (If you want to write your own specialized registration code study the registration examples)
- The function point_registration is fast fitting of a b-spline grid to 2D/3D corresponding points, for landmark based registration.
- There is also the function manually_warp_images which allow control grid changes with the mouse, to get better registration.
First, you need to compile mex / C code with compile_c_files.m. (2D registration also works without mex files but will be slower)
The multi-threaded mex code supports Windows, Linux (and Mac OS?)
Some Features:
- 2-D / 3-D Eulerian strain tensor images can be made from the transformations fields. For example to describe cardiac motion in the images.
- Landmarks can be used for already known corresponding points (for example from Sift). Influence of every landmark on the registration process can be adjust.
- It is possible to register a number of movie frames by using the registration grid of previous two images as initial registration grid of the next two images.
- It is possible to mask parts of the images, to decrease or increase the influence of an image structure on the registration result.
Literature:
- D. Rueckert et al. "Nonrigid Registration Using Free-Form Deformations: Application to Breast MR Images".
- Seungyong Lee, George Wolberg, and Sung Yong Shing, "Scattered Data interpolation with Multilevel B-splines"
note:
- B-spline registration is slower and more complex than demon registration see:
http://www.mathworks.fr/matlabcentral/fileexchange/loadFile.do?objectId=21451
- Why still use B-spine registration?, because the resulting transformation-field corresponds better to real-live deformation than transformation fields from fluid registration.
Please report bugs, successes and questions.
Cite As
Dirk-Jan Kroon (2025). B-spline Grid, Image and Point based Registration (https://www.mathworks.com/matlabcentral/fileexchange/20057-b-spline-grid-image-and-point-based-registration), MATLAB Central File Exchange. Retrieved January 14, 2025.
functions/
- backwards2forwards(B)
- backwards2forwards_2d_double(Bx,By,H)
- fminlbfgs.m
- image_difference(V,U,type,Mask,MaskNum)
- imgaussian(I,sigma,siz)
- imresize3d(V,scale,tsize,ntype,npad)
- inversegrid(O_trans,Spacing,sizeI,MaxRef)
- MakeDiffeomorphic(O_trans,Spacing,sizeI)
- make_grid_image(Spacing,sizeI)
- make_init_grid(Spacing,sizeI,M)
- maxNumCompThreads(varargin)
- mutual_histogram_double(I1,I2,Imin,Imax,nbins)
- penalties_smoothness(O,sizeI,Scaling)
- refine_grid(O_trans,Spacing,sizeI)
- showcs3(varargin)
- squared_difference_double(V,U)
- strain(Ux,Uy,Uz)
functions_affine/
- affine_parameter_scaling(sizeI)
- affine_registration_error(par,scale,I1,I2,type,O_trans,Spacing,MaskI1,MaskI2,Points1,Points2,PStrength,mode)
- affine_registration_image(par,scale,I1,I2,type)
- affine_transform(Iin,M,mode)
- affine_transform_2d_double(Iin,M,mode,ImageSize)
- make_transformation_matrix(t,r,s,h)
functions_nonrigid/
- bspline_coefficients(u,v,w)
- bspline_grid_fitting(O,Spacing,D,X)
- bspline_registration_gradient(O_grid,sizes,Spacing,I1,I2,options,MaskI1,MaskI2,Points1,Points2,PStrength)
- bspline_registration_image(O_grid,sizes,Spacing,I1,I2,type)
- bspline_transform(O,I,Spacing,mode)
- bspline_transform_2d_double(Ox,Oy,Iin,dx,dy,mode)
- bspline_trans_points_double(O_trans,Spacing,X,check)
- image_interpolation(Iin,Tlocalx,Tlocaly,Interpolation,Boundary,ImageSize)
- jacobiandet_cost_gradient(O_grid,sizes,O_goal,sizeI,Spacing)
- jacobiandet_error_2d_double(Ox,Oy,sizeI,dx,dy)
- jacobiandet_transform_2d_double(Ox,Oy,Isize,dx,dy)
- movepixels(I1,T,mode)
- movepixels_2d_double(Iin,Tx,Ty,mode)
low_level_examples/
Version | Published | Release Notes | |
---|---|---|---|
1.33.0.0 | 16 Mar 2011 | Solved Bugs in diffeomorphic functions. Tested in Ubuntu and with LCC compiler | Download |
1.32.0.0 | 15 Mar 2011 | Added MakeDiffeomorphic for deformations without folding. New clean multi-threading c-code. | Download |
1.31.0.0 | 13 Sep 2010 | Fixed Nan in SSD calculation. Added numerical b-spline inverse. Added bi-cubic code | Download |
1.30.0.0 | 2 Sep 2010 | Major Update! Improved / fixed bugs in "Mutual information", new affine weighting par. in 3D. Fixed bug, which caused the error to decrease after refining a few times to a very fine b-spline grid. Added Point Registration examples. | Download |
1.29.0.0 | 30 Aug 2010 | Added Corresponding Point based registration of Lee. Merged 2D and 3D registration functions into one file. Replaced for-loops by faster 1D index operations. | Download |
1.28.0.0 | 11 Jan 2010 | Added manually_warp_images function. Now uses localized mutual information for the error calculation, not only for the gradient of the error. Split register_images and register_volumes in sub-functions. | Download |
1.27.0.0 | 30 Sep 2009 | Fixes for Linux Compiler | Download |
1.26.0.0 | 28 Sep 2009 | Fixed bug, 3D registration empty Fx and Fz matrix. | Download |
1.25.0.0 | 8 Sep 2009 | Fix Gaussian filter function | Download |
1.23.0.0 | 14 Aug 2009 | Fixed Single cubic interpolation bug, and addpaths.m in low_level_examples | Download |
1.22.0.0 | 5 Aug 2009 | Solved mask bug reported by siamak yousefi.Also changed default smoothness penalty from 0.001 to 0.01 , which is probably better for most applications. | Download |
1.21.0.0 | 27 Jul 2009 | Major code speed up by look up tables and separate SDD code. Also some bug Fixes in Mask code... | Download |
1.20.0.0 | 15 Jul 2009 | Major bug z-dimension fixed in volume registration | Download |
1.19.0.0 | 15 Jul 2009 | Bug fixed in index 3D cubic interpolation, resulted in zero resulting volumes | Download |
1.18.0.0 | 14 Jul 2009 | Minor bug, Mask is now resized to fit size Istatic (if not already). | Download |
1.17.0.0 | 13 Jul 2009 | Added Cubic interpolation!, fixed bug and comment in masks mutual information, interpolation now in separate file c. file | Download |
1.16.0.0 | 4 Jun 2009 | example 3d nonrigid fixed | Download |
1.15.0.0 | 2 Jun 2009 | Bug LCC compiler doesn't link floorf fixed. Also fixed NaN bug in image_difference.m | Download |
1.14.0.0 | 29 May 2009 | Tri Ngo provided me with Linux multi-threaded code, which I added, thus the registration now supports multi-threaded Windows, Linux and (Mac Os)? Also fixed last ; bug ... | Download |
1.13.0.0 | 27 May 2009 | ";" removed to fix a boundary bug | Download |
1.12.0.0 | 26 May 2009 | Speed up affine 3D registration (2x), and some other small improvements. | Download |
1.11.0.0 | 15 Apr 2009 | Added 2D RGB image support | Download |
1.10.0.0 | 14 Apr 2009 | Landmarks can now be used as transformation regularization. | Download |
1.9.0.0 | 25 Mar 2009 | Fixed out of bounds bug, reported by D.C. Karhoff | Download |
1.8.0.0 | 24 Mar 2009 | Bug fixed in image dimensions in backwards2forward c-code and updated movepixels files to allow pixels outside image to be zero or nearest value inside image. | Download |
1.7.0.0 | 20 Mar 2009 | Changed parameter "size of region influenced by a control point" in final refinement step. Resulting in a speed up of 150% in gradient calculation in this last step. | Download |
1.6.0.0 | 19 Mar 2009 | Fixed a bug: The moving grid was used to determine the region influenced by a control point in gradient registration, this is changed in a uniform static grid. (b-splines are always determined on a uniform grid). | Download |
1.5.0.0 | 16 Mar 2009 | Multi-threaded registration now uses the number of threads set by maxNumCompThreads. New Quasi newton optimizer fminlbfgs. Speed ups in the smoothness penalty, and some other files. | Download |
1.4.0.0 | 4 Mar 2009 | Single Threaded files are updated to all code in the Multiple Threaded files, and tested... | Download |
1.3.0.0 | 24 Feb 2009 | 2D available in 100% Matlab code. Eulerian strain images available. Parts of images can be masked. Forward transformation field now also available. | Download |
1.1.0.0 | 31 Oct 2008 | Bug fixed: The rigid transformation optimizers crashed with images with strange dimensions | Download |
1.0.0.0 | 13 Oct 2008 | Added registration smoothness penalty. | Download |