Skip to content
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

Feature: Allow configuring interpolation and extrapolation behavior #60

Open
lorenzoh opened this issue Mar 13, 2022 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@lorenzoh
Copy link
Member

lorenzoh commented Mar 13, 2022

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:

  • extrapolation:
    • for Images: set to 0 (warp(..., zero(T)) see image.jl:80)
    • for Mask[Multi]s: flat extrapolation, i.e. value of the boundary (see mask.jl:146). This avoids creating invalid class values.
  • interpolation:
    • for Images: Linear interpolation
    • for Masks: nearest neighbor interpolation. . This avoids creating invalid class values.

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.

@lorenzoh lorenzoh added the enhancement New feature or request label Mar 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant