If you are aiming for generality, it is worthwhile to look into ITKElastix. A new version was just announced.