FluxML / DataAugmentation.jl

Flexible data augmentation library for machine and deep learning
https://fluxml.ai/DataAugmentation.jl/dev/
MIT License
41 stars 17 forks source link

Feature: Allow configuring interpolation and extrapolation behavior #60

Open lorenzoh opened 2 years ago

lorenzoh commented 2 years ago

More customization for interpolation and (especially) extrapolation would be nice to have. Interpolation here refers to how the values of projected pixels that fall into the transformed content bounds are calculated, and extrapolation refers to those that fall outside the projected content bounds. For example, rotating an image will often result in regions that need to be filled in (extrapolated).

Documentation of the current behavior:

To make this configurable, one could add interpolation methods to all ProjectiveTransforms. There are two problems with this: (1) as seen above, different items should support different behaviors and one would have to be able to pass a method for every item type, and (2) composing transforms with different interpolation methods would be a hassle.

Instead, I think interpolation conditions should be added to the Item types. This could allow using a custom boundary condition by specifiying Image((100, 100), interpolate=BSpline(Linear()), extrapolate=Reflect()).

The default behavior should also change: like in fast.ai, images should have Reflect extrapolation and cubic interpolation by default. Masks should also have Reflect extrapolation to match the images.

Changing the defaults would be considered a breaking change.