Algorithm using a MRF for image registration.
infoI = dicominfo('thorac.dcm');
I=dicomread(infoI); % image that will be transformed.
infoJ = dicominfo('thorac2.dcm');
J=dicomread(infoJ); % image that will model the transformation.
Running the algorithm. The variable IT will become the registered image, the 3rd parameter is the number of iterations that will be performed, we recommend between 25 and 30 iterations.
IT = MRF(I,J,30);
IJSAD = SAD(I,J);
To calculate the Sum Absolute Difference between the registered image and the target images, we run:
ITJSAD = SAD(IT,J);
subplot(3,1,1)
imshow(I,[]);
title("Image I");
subplot(3,1,2)
imshow(IT, []) ;
title("Transformed Image");
subplot(3,1,3)
imshow(J,[]);
title("Image J");