Updated functions for image registration