Other Image Processing Topics
In this 7th article of the image processing series, we will discuss homographgy matrix and texture metrics. We will learn its importance, functionalities, and applications.
In this article, we will be using the scikit-image library to transform our images.
Homography Matrix
The homography matrix is a powerful tool in image processing. It enables one to distort an image with control. A homography matrix is a 3x3 matrix with 8 degrees of freedom.
For example, we need our computer to map out the pieces on this chessboard. Since it is taken from an angle, it will pose a challenge to the computer to determine the piece location. Although it is possible, we can simplify it by transforming the chessboard into a top-down view.
To transform the chessboard, we will first have to get the coordinates of its corners.
src = np.array([391, 100,
14, 271,
347, 624,
747, 298,
]).reshape((4, 2))
Next, we determine the target location of these points. Since we want to get a top down view, the destination coordinates will form a square.
dst = np.array([100, 100,
100, 650,
650, 650,
650, 100,
]).reshape((4, 2))
Now that we have these values, we can transform the image using skimage
from skimage import transform
tform = transform.estimate_transform('projective', src, dst)tf_img = transform.warp(chess, tform.inverse)
fig, ax = plt.subplots()
ax.imshow(tf_img)
_ = ax.set_title('projective transformation')