An A∗ perspective on deterministic optimization for deformable templates