ZFTurbo / volumentations

Library for 3D augmentations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apply same augmentation to different images

elenadoe opened this issue · comments

Thank you for this very valuable tool! I'm working on an image-to-image translation task, where I would like to apply the same transformations (augmentations) to input and ground truth images. Is there any way to do this?

I thought that retrieving one augmentation instance per (input, ground truth) tuple might solve the issue. To test this, I entered an (input, input) tuple into the following code and tested whether the augmented images in data_aug are equal. However, this program returns False (although the images visually look the same). This was programmed using 3D scans and volumentations-3D.

def get_augmentation(patch_size):
    return Compose([
        Rotate((-15, 15), (0, 0), (0, 0), p=0.5),
        ElasticTransform((0, 0.25), interpolation=2, p=0.1),
        Flip(0, p=0.5),
    ], p=1.0)

aug = get_augmentation((79, 95, 79))  # 79, 95, 79 is the whole image, not a patch

data = {'image': np.array([input_img, input_img])}
data_aug = aug(**data)
img = data_aug['image']

print((img[0] == img[1]).all())  # this returns False

Moreover, sometimes one of the augmented images is blank. Could there be a mistake in the provided code, which causes this issue?

Thank you in advance and best wishes
Elena