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.
- 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?)
- 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.
- 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"
- B-spline registration is slower and more complex than demon registration see:
- 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.
Dirk-Jan Kroon (2023). 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 .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
- Image Processing and Computer Vision > Image Processing Toolbox > Geometric Transformation and Image Registration >
- MATLAB > Graphics > Images > Read, Write, and Modify Image >
- Image Processing and Computer Vision > Computer Vision Toolbox > Recognition, Object Detection, and Semantic Segmentation > Image Category Classification >
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Solved Bugs in diffeomorphic functions. Tested in Ubuntu and with LCC compiler
Added MakeDiffeomorphic for deformations without folding. New clean multi-threading c-code.
Fixed Nan in SSD calculation. Added numerical b-spline inverse. Added bi-cubic code
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.
Added Corresponding Point based registration of Lee. Merged 2D and 3D registration functions into one file. Replaced for-loops by faster 1D index operations.
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.
Fixes for Linux Compiler
Fixed bug, 3D registration empty Fx and Fz matrix.
Fix Gaussian filter function
Fixed Single cubic interpolation bug, and addpaths.m in low_level_examples
Solved mask bug reported by siamak yousefi.
Major code speed up by look up tables and separate SDD code. Also some bug Fixes in Mask code...
Major bug z-dimension fixed in volume registration
Bug fixed in index 3D cubic interpolation, resulted in zero resulting volumes
Minor bug, Mask is now resized to fit size Istatic (if not already).
Added Cubic interpolation!, fixed bug and comment in masks mutual information, interpolation now in separate file c. file
example 3d nonrigid fixed
Bug LCC compiler doesn't link floorf fixed. Also fixed NaN bug in image_difference.m
Tri Ngo provided me with Linux multi-threaded code, which I added, thus the registration now supports multi-threaded Windows, Linux and (Mac Os)?
";" removed to fix a boundary bug
Speed up affine 3D registration (2x), and some other small improvements.
Added 2D RGB image support
Landmarks can now be used as transformation regularization.
Fixed out of bounds bug, reported by D.C. Karhoff
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.
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.
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).
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.
Single Threaded files are updated to all code in the Multiple Threaded files, and tested...
2D available in 100% Matlab code. Eulerian strain images available. Parts of images can be masked. Forward transformation field now also available.
Bug fixed: The rigid transformation optimizers crashed with images with strange dimensions
Added registration smoothness penalty.