aleju / imgaug

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

Pad with pad mode 'wrap' does not duplicates boxes #726

Open assafzam opened 4 years ago

assafzam commented 4 years ago

Is there a way to use Pad (For example iaa.PadToSquare) with pad mode wrap or reflect that will duplicate also the boxes. for example:

image = imageio.imread('example.jpg')

bbs = BoundingBoxesOnImage([
    BoundingBox(x1=300, y1= 100, x2=600, y2=400),
    BoundingBox(x1=720, y1= 150, x2=800, y2=230),
], shape=image.shape)

image_before = bbs.draw_on_image(image, size=2)
ia.imshow(image_before)

image

seq = iaa.Sequential([
    iaa.PadToSquare(position='right-top', pad_mode='wrap'),
])

image_aug, bbs_aug = seq(image=image, bounding_boxes=bbs)
image_after = bbs_aug.draw_on_image(image_aug, size=2, color=[0, 0, 255])
ia.imshow(image_after)

image

and the boxes are missing in the newly duplicated parts of the image.

Thanks a lot.