% Clean clc; clear all; close all;
% Compile the mex files %compile_c_files
% Read two images I1=im2double(imread('ssftrinew1.png'));
I2=im2double(imread('ssftri.png'));
% Set static and moving image S=I2; M=I1;
% Alpha (noise) constant alpha=2.5;
% Velocity field smoothing kernel Hsmooth=fspecial('gaussian',[60 60],10);
% The transformation fields Tx=zeros(size(M)); Ty=zeros(size(M)); Tz=zeros(size(M));
[Sy,Sx] = gradient(S); for itt=1:200 % Difference image between moving and static image Idiff=M-S;
% Default demon force, (Thirion 1998) %Ux = -(Idiff.*Sx)./((Sx.^2+Sy.^2)+Idiff.^2); %Uy = -(Idiff.*Sy)./((Sx.^2+Sy.^2)+Idiff.^2);
% Extended demon force. With forces from the gradients from both % moving as static image. (Cachier 1999,