Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect rotation of segmentation map when mode="symmetric" #815

Open
gui-miotto opened this issue Apr 19, 2022 · 0 comments · May be fixed by #816
Open

Incorrect rotation of segmentation map when mode="symmetric" #815

gui-miotto opened this issue Apr 19, 2022 · 0 comments · May be fixed by #816

Comments

@gui-miotto
Copy link

gui-miotto commented Apr 19, 2022

When applying a rotation with symmetric mode (i.e. padding mode) the segmentation map is not mirrored accordingly. The rotation of the map is fine, just its padding is missing.

Reproduction
I modified one of your examples to demonstrate the problem:

import numpy as np
import imgaug as ia
import imgaug.augmenters as iaa
from imgaug.augmentables.segmaps import SegmentationMapsOnImage
import matplotlib.pyplot as plt

# Load an example image (uint8, 128x128x3).
image = ia.quokka(size=(128, 128), extract="square")

# Define an example segmentation map (int32, 128x128).
# Here, we arbitrarily place some squares on the image.
# Class 0 is our intended background class.
segmap = np.zeros((128, 128, 1), dtype=np.int32)
segmap[28:71, 35:85, 0] = 1
segmap[10:25, 30:45, 0] = 2
segmap[10:25, 70:85, 0] = 3
segmap[10:110, 5:10, 0] = 4
segmap[118:123, 10:110, 0] = 5
segmap = SegmentationMapsOnImage(segmap, shape=image.shape)

# Define our augmentation pipeline.
seq = iaa.Sequential([
    iaa.Affine(rotate=-45, mode="symmetric"),  # if we don't use mode="symmetric", the final result is correct.
])

image_aug, segmaps_aug = seq(image=image, segmentation_maps=segmap)

overlay = segmaps_aug.draw_on_image(image_aug)[0]
plt.imshow(overlay)
plt.show()

Result
seg_problem

Expected result
seg_problem_correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant