Euclidian Distance Correction Algorithm