aleju / imgaug

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

How can I augment images and corresponding masks with the same operation? #86

Open gasvn opened 6 years ago

gasvn commented 6 years ago

I already have images and corresponding masks. And I wanna augment images and masks with the same operation, so that they can still match each other after augmention. I have checked the docs, but failed to look for a solution. Can I make that happen using IMGAUG?

gasvn commented 6 years ago

Thanks to issues 41, I made it.

lucidyan commented 6 years ago

For those who are lost, like me, I'll tell you the solution. You need to call _aug = augmentation._to_deterministic()

before each generation of a new pair [Image, Mask] with

new_img = _aug.augment_image(img)
new_mask = _aug.augment_image(mask)
mpkuse commented 5 years ago

So far so good, but augment_image() also applies for example gaussian noise to mask which is not what people usually want. Any better way to avoid such operations as Gaussian noise etc (ie. only allow geometry ops)

aleju commented 5 years ago

See the documentation for segmentation maps, which only applies geometry ops. Should also work with masks.

If that doesn't work you can also use Hooks or create a second augmentation pipeline and copy the random states from the first to the second, but both of these options are a bit more difficult to implement than the first one.