aleju / imgaug

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

Can image augmentation without cutting the augmented result? #141

Open hellozgm opened 6 years ago

hellozgm commented 6 years ago

Many image augmentation method such as Affine rotation and PerspectiveTransform may generate the cutting augmented result. Here is an example, after I rotate the lenna image by 45 degree, the default Affine method generate the cutting edge result: lenna_rotation

But I want the rotation keep all augmented image edges, like this:

lenna_rotation_scale

So, are there any way to do so? Many thanks!

aleju commented 6 years ago

No, that's currently not possible. I think the waiting pull request would have added something in that direction to scikit-image's affine warping function, which then could have been added to Affine, but so far it was not merged to scikit-image. So the only way here to do this is to manually compute scalings that don't remove image content given sampled rotation and shearing values. But would require a partial rewrite of Affine, as scale, rotation and shear are sampled independently from each other.

For PerspectiveTransform it would be even harder as that augmenter currently samples a subpolygon within the image and "zooms into" that, thereby removing anything outside of the polygon.

hellozgm commented 6 years ago

OK, I would try your suggestion, thanks for your reply.