def _center_and_normalize_points(points):
 centroid = np.mean(points, axis=0)
 rms = math.sqrt((np.sum(((points - centroid) ** 2)) / points.shape[0]))
 norm_factor = (math.sqrt(2) / rms)
 matrix = np.array([[norm_factor, 0, ((- norm_factor) * centroid[0])], [0, norm_factor, ((- norm_factor) * centroid[1])], [0, 0, 1]])
 pointsh = np.row_stack([points.T, np.ones(points.shape[0])])
 new_pointsh = np.dot(matrix, pointsh).T
 new_points = new_pointsh[:, :2]
 new_points[:, 0] /= new_pointsh[:, 2]
 new_points[:, 1] /= new_pointsh[:, 2]
 return (matrix, new_points)

def _center_and_normalize_points ( points ) : centroid = np . mean ( points , axis = 0 ) rms = math . sqrt ( ( np . sum ( ( ( points - centroid ) ** 2 ) ) / points . shape [ 0 ] ) ) norm_factor = ( math . sqrt ( 2 ) / rms ) matrix = np . array ( [ [ norm_factor , 0 , ( ( - norm_factor ) * centroid [ 0 ] ) ] , [ 0 , norm_factor , ( ( - norm_factor ) * centroid [ 1 ] ) ] , [ 0 , 0 , 1 ] ] ) pointsh = np . row_stack ( [ points . T , np . ones ( points . shape [ 0 ] ) ] ) new_pointsh = np . dot ( matrix , pointsh ) . T new_points = new_pointsh [ : , : 2 ] new_points [ : , 0 ] /= new_pointsh [ : , 2 ] new_points [ : , 1 ] /= new_pointsh [ : , 2 ] return ( matrix , new_points )
center and normalize image points .