aleju / imgaug

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

rotated bounding boxes are not as tight as they should be #776

Open haniehm opened 3 years ago

haniehm commented 3 years ago

I am using aug = iaa.Affine(rotate=(-45, 45)) to augment my images and their bounding boxes.

The bounding boxes on original nonaugmented images are drawn as tight as possible.

I am taking following steps to generated bounding boxes for augmented images. However, the resulted bounding box is not as tight as what "best practice" is recommending.

Are there any ways to improve this and have tighter and more accurate bounding boxes for augmented images?

get bounding boxes coordinates and write into array

bb_array = group_df.drop(['filename', 'width', 'height', 'class'], axis=1).values

pass the array of bounding boxes coordinates to the imgaug library

bbs = BoundingBoxesOnImage.from_xyxy_array(bb_array, shape=image.shape)

apply augmentation on image and on the bounding boxes

image_aug, bbs_aug = augmentor(image=image, bounding_boxes=bbs)

disregard bounding boxes which have fallen out of image pane

bbs_aug = bbs_aug.remove_out_of_image()

clip bounding boxes which are partially outside of image pane

bbs_aug = bbs_aug.clip_out_of_image()
figkim commented 3 years ago

+1

tooHotSpot commented 3 years ago

+1