File Exchange

image thumbnail

Diffeomorphic Log Demons Image Registration

version 1.7 (195 KB) by

Simple matlab code for 2D and 3D image registration using the diffeomorphic log-demons algorithm



View License

Simple matlab code for 2D and 3D image registration using the diffeomorphic log-demons algorithm
Code is provided in order to help the understanding of the Demons algorithm - Any comment or improvement is welcome

Comments and Ratings (13)


S (view profile)

you DO know that it doesn't work for the basic circle to C case? it works only so much as it does _something_ - but it's nowhere near any sensible registration for any pair of images even simple ones that should be easy. thanks for the effort in any case.

jakeoung koo

Can I know about expfield function exponentiating vector field?

I have read some literature but I don't know how to calculate exponential field. So I don't understand the function.

zhang le

I am confused that I can not get the same result showing in Fig. 6 ( Classical Circle to C registration example)


Nikita (view profile)

Please let me know what changes should be incorporated to work on RGB images.

Nicolas Yu

Nicolas Yu (view profile)

Some details should be changed for my purpose, and thanks.

Xun Zhang

I'm running the 2D demons. I'm confused about findupdate.m. In findupdate.m, your code computes the gradient of the moving image or float image. As far as I have learnt from literature, gradient of fixed image are used in the expression for u. I'm not quite clear about this.

Herve Lombaert

@tianyu - You are raising an interesting point - There is a difference between Displacement field != Transformation (zero displacement leads to an identity matrix)

Typically, the identity matrix is added when computing the Jacobian determinant

See also this thread (from the itk code): (code is now including additional comments, perhaps this would help others)

tianyu fu

@Herve LomBaert: And I don't think the code is wrong.But I can't get the same result showing in the paper.This makes me very upset.

tianyu fu

@Herve LomBaert: Thank you for your reply.I have read many papers about the diffeomorphic Log-Demons.As you know,if the registration is diffeomorphic,so the Jacobian determinant of deformation must be positive.But,running your code,I find the determinant sometimes is negative.

Herve Lombaert

@tianyu - Indeed, this is the Log-domain Diffeomorphic version, the deformation field is defined as the exponential map of a velocity field via expfield() - (velocity field != deformation field - More details on the associated literature on the Diffeomorphic Log-Demons)

tianyu fu

Is it Diffeomorphic Image Registration?I do not think the Jacobi determinant of the transformation field is positive.

@Hg: in image registration, you have to know how to deal with the boundaries of the images. A common choice is to have them fixed. So, in order not to over-regularize nor violate the diffeomorphism, a band of zeros is added during optimization.


Hg (view profile)

May I know the purpose of the piggyback function? Where can I find the explanation for the algorithm used in the code other than the paper included in the package?



comment updates


Fix in 2D (adding comments regarding Jacobian computation)


Log domain


cleanup in sample files

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video