Code covered by the BSD License

# B-spline Grid, Image and Point based Registration

### Dirk-Jan Kroon (view profile)

26 May 2008 (Updated )

B-spline registration of two 2D / 3D images or corrsp. points, affine and with smooth b-spline grid.

E=strain(Ux,Uy,Uz)
```function E=strain(Ux,Uy,Uz)
% Calculate the Eulerian strain from displacement images
%
%  E = STRAIN(Ux,Uy)   or (3D)  E = STRAIN(Ux,Uy, Uz)
%
% inputs,
%   Ux,Uy: The displacement vector images in
%           x and y direction (same as registration variables Tx, Ty)
%   Uz: The displacement vector image in z direction.
%
% outputs,
%   E the 3-D Eulerian strain tensor images defined by Lai et al. 1993
%      with dimensions [SizeX SizeY 2 2] or in 3D [SizeX SizeY SizeZ 3 3]
%
% Source used:
%   Khaled Z et al. "Direct Three-Dimensional Myocardial Strain Tensor
%   Quantification and Tracking using zHARP"
%
% Function is written by D.Kroon University of Twente (February 2009)

if(~exist('Uz','var')) % Detect if 2D or 3D inputs
% Initialize output matrix
E=zeros([size(Ux) 2 2]);
% Loop through all pixel locations
for i=1:size(Ux,1)
for j=1:size(Ux,2)
% the 3-D Eulerian strain tensor
e=(1/2)*([1 0;0 1]-Finv*Finv');
% Store tensor in the output matrix
E(i,j,:,:)=e;
end
end
else
% Initialize output matrix
E=zeros([size(Ux) 3 3]);
% Loop through all pixel locations
for i=1:size(Ux,1)
for j=1:size(Ux,2)
for k=1:size(Ux,3)
Ugrad=[Uxx(i,j,k) Uxy(i,j,k) Uxz(i,j,k); Uyx(i,j,k) Uyy(i,j,k) Uyz(i,j,k);Uzx(i,j,k) Uzy(i,j,k) Uzz(i,j,k)];
Finv=[1 0 0;0 1 0;0 0 1]-Ugrad; %F=inv(Finv);
% the 3-D Eulerian strain tensor
e=(1/2)*([1 0 0;0 1 0;0 0 1]-Finv*Finv');
% Store tensor in the output matrix
E(i,j,k,:,:)=e;
end
end
end
end

```