I've added implementation of the function that calculates an affine transformation normalizing given image.