Affine Image Transformations in Python with Numpy, Pillow and OpenCV

python_tutorials

In this article I will be describing what it means to apply an affine transformation to an image and how to do it in Python. First I will demonstrate the low level operations in Numpy to give a detailed geometric implementation. Then I will segue those into a more practical usage of the Python Pillow and OpenCV libraries.

This article was written using a Jupyter notebook and the source can be found at my GitHub repo so, please feel free to clone / fork it and experiment with the code.

What is an Affine Transformation

According to Wikipedia an affine transformation is a functional mapping between two geometric (affine) spaces which preserve points, straight and parallel lines as well as ratios between points. All that mathy abstract wording boils down is a loosely speaking linear transformation that results in, at least in the context of image processing, one or more manipulations like rotating, flipping, scaling or shearing by applying a transformation matrix.

One good thing is that since this is essentially a 2D geometric operation we can visualize it. Let me start off

To finish reading, please visit source site