albumentations
albumentations copied to clipboard
`CropAndPad` interpolation doesn't default to `INTER_NEAREST` for masks
🐛 Bug
Interpolation mode for masks should default to INTER_NEAREST
when CropAndPad is applied to masks.
To Reproduce
t = A.CropAndPad(percent=(-0.25, 0.25), p=1)
x = np.random.randn(80, 80).astype(np.uint8)
x[x>0] = 255
xx = t(image=x, mask=x)['mask']
np.unique(xx) # 0 1 2 .. 255
Expected behavior
t = A.CropAndPad(percent=(-0.25, 0.25), interpolation=cv2.INTER_NEAREST)
xx = t(image=x, mask=x)['mask']
np.unique(xx) # 0, 255
Environment
- Albumentations version: 1.1.0
- Python version (e.g., 3.7): 3.9.5
- OS (e.g., Linux): Ubuntu 21.04
- How you installed albumentations (
conda
,pip
, source):pip install -U albumentations
- Any other relevant information:
Related with #850