Structural image restoration through deformable templates