imgaug
imgaug copied to clipboard
Question: How to return the transformation matrix from the imgaug.augmenters.geometric?
Hello, I successfully created used iaa.PerspectiveTransform(scale=(0.01, 0.30)) on a batch of images. Now I would like to get the transformation matrix (i.e. the Prespective Transformation matrix) that lead from the original image to the augmented image. How do I get it?
There is no trivial way to do this, but you can re-generate the matrices. Something like the following should usually work (didn't test it though):
import imgaug.augmenters as iaa
import imgaug as ia
import numpy as np
# input images
images = [
np.zeros((64, 64, 3), dtype=np.uint8),
np.ones((128, 100, 3), dtype=np.uint8)
]
# augmenter
aug = iaa.PerspectiveTransform(scale=0.5, seed=1234)
# create matrices
samples = aug._draw_samples(
shapes=[image.shape for image in images],
random_state=aug.random_state.copy()
)
matrices = samples.matrices
# augment images
images_aug = aug(images=images)
Sorry for the late reply.
Hi, it seems the above code snippet does not quite work. Has the functions/parameters name been updated?
How to get matrix from affine transformation? @aleju