Estimate rigid transformation given a set of indices

        :param idx: Array of indices used to estimate the transformation
        :return: Estimated transformation matrix

def estimate_rigid_transformation(self, idx):
        """ Estimate rigid transformation given a set of indices

        :param idx: Array of indices used to estimate the transformation
        :return: Estimated transformation matrix
        """
        # Look at points of given indices only
        src_pts = self.src_pts[idx, :]
        trg_pts = self.trg_pts[idx, :]
        # Get centroid location
        src_centroid, trg_centroid = np.mean(src_pts, axis=0), np.mean(trg_pts, axis=0)
        # Centre sets of points
        src_pts_centr = src_pts - src_centroid
        trg_pts_centr = trg_pts - trg_centroid
        # SVD decomposition
        u, _, v = np.linalg.svd(np.matmul(src_pts_centr.transpose(), trg_pts_centr))
        e = np.eye(2)
        e[1, 1] = np.linalg.det(np.matmul(v.transpose(), u.transpose()))
        # Estimate rotation matrix
        r = np.matmul(v.transpose(), np.matmul(e, u.transpose()))
        # Estimate translation
        t = trg_centroid - np.matmul(r, src_centroid.transpose()).transpose()
        # Fill in transformation matrix and return
        warp_matrix = np.zeros((2, 3))
        warp_matrix[:2, :2] = r
        warp_matrix[:, 2] = t
        return warp_matrix