Hey thanks for the code,
but the error that persists is that in the noisy data again the fitting is coming out to be wrong. It fits the co-ordinates the data for noisy data as well.
I am implementing the code on a Image processing method.
12 May 2014
Perform closest point search or range query using a k-D tree implementation.