aleju / imgaug

Image augmentation for machine learning experiments.
http://imgaug.readthedocs.io
MIT License
14.43k stars 2.44k forks source link

Keypoint transformation while doing fliplr #769

Closed baheytharwat closed 3 years ago

baheytharwat commented 3 years ago

Thank you guys for the great work! your efforts are appreciated. I wanted to do some transformation on an image and transform a keypoint with the same transformation. so I used

        seq = iaa.Sequential([
            iaa.Fliplr(0.5), # horizontal flips
            iaa.Affine(
                rotate=10,
                scale={"x": (0.8, 1.2), "y": (0.8, 1.2)},
            ) # rotate by exactly 10deg and scale to 50-70%, affects keypoints
        ])

          kps = KeypointsOnImage([
              Keypoint(x=center[0], y=center[1])
          ], shape=img.shape)

          img, kps = seq(image=img, keypoints=kps)
          center[0] = kps.keypoints[0].x
          center[1] = kps.keypoints[0].y

But I noticed that there are some problems with the Fliplr, the x component is not transformed by the flipping. I expect the new x should be img width - old x. I see the x doesn't change and the transformation(Rotation and scale) works fine without the flipping.

Cospel commented 1 year ago

Anyone solved this?

jren03 commented 4 months ago

I've also observed something similar in imgaug == 0.4.0. Curious if there's been a solution to this?