-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Global config padding value for masks? #710
Comments
You might want to take a look at the
link to the documentation: https://imgaug.readthedocs.io/en/latest/source/api_augmenters_pillike.html#imgaug.augmenters.pillike.Affine Best |
Hi @jspaezp
And when using iaa.Affine as suggested, there is the cval argument (similar to fillcolor) that can be passed, however this value is used to fill the image and not the segmentation map. My problem is with segmentation maps in Cityscapes-like datasets, where the 0 value is used for labeling the road and 255 is used for void. Whether the image will be padded by random, constant values or reflection, is not that relevant as the padding in segmentation, which can be confusing. I looked into the library and could not find a nice way to set the segmentation pad value, but I hope for a proper workaround until hopefully it will be added in the next release. |
ohhh, I see the issue (on the question it seemed like the problem was in the image side and not the segmaps). Well ... It might not be ideal for your application but you could try to re-code your segmap before passing it to the augmentator and the decode it later. something like ... import numpy as np
# Creating a fake segmap
foo = np.zeros(shape = (6,6))
foo[2:5, 2:5] = 255
foo
# array([[ 0., 0., 0., 0., 0., 0.],
# [ 0., 0., 0., 0., 0., 0.],
# [ 0., 0., 255., 255., 255., 0.],
# [ 0., 0., 255., 255., 255., 0.],
# [ 0., 0., 255., 255., 255., 0.],
# [ 0., 0., 0., 0., 0., 0.]])
# Possibly define this as a function ...
streets = foo == 0
voids = foo == 255
foo[streets] = 255
foo[voids] = 0
foo
# array([[255., 255., 255., 255., 255., 255.],
# [255., 255., 255., 255., 255., 255.],
# [255., 255., 0., 0., 0., 255.],
# [255., 255., 0., 0., 0., 255.],
# [255., 255., 0., 0., 0., 255.],
# [255., 255., 255., 255., 255., 255.]]) let me know if it helps, |
Thanks and sorry for ambiguous description. That is my workaround right now and it works. I was hoping either passing this padding value to imgaug or get help for writing my own setter for SegmentationMapsOnImage however it seems that one needs to consider many things before setting the cval(s) in that class, because those methods are used for many augmentations and changing it might mess things up. |
Is there a way to change the default padding value from 0 to another value for all segmentation mask augmentations without manually changing the default passed values in the library functions?
The problem occurs when I use augmentations such as geometric affine transformations, where new pixel values are added to the image (e.g. bottom right part of the image below).

For these newly added pixels I get zeroes in the segmentation maps, however the value 0 is used for another class and the ignore label value is 255. So I would like to set the default padding value for segmentations to 255 so that all added pixels in the paddings are ignored during the training.
The text was updated successfully, but these errors were encountered: