Skip to content

tfa.image.transform interpolates pixels that are outside image boundary (instead of using fill_value) #2357

@eli-osherovich

Description

@eli-osherovich

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Debian testing
  • TensorFlow version and how it was installed (source or binary): 2.4.0 (binary)
  • TensorFlow-Addons version and how it was installed (source or binary): 0.12.0 (binary)
  • Python version: 3.8
  • Is GPU used? (yes/no): no

Describe the bug

tfa.image.transform interpolates pixels that are outside image boundary (instead of using fill_value)
In the example below, the corner pixels are mapped from coordinates that lie outside the image. Hence, they must be set to fill_value (like, for example, scipy.ndimage.affine_transform and skimage.transform.AffineTransform). However, they are interpolated.

Code to reproduce the issue

import numpy as np
import tensorflow as tf
import tensorflow_addons as tfa

a = np.ones((3,3))
tfa.image.rotate(a, np.deg2rad(45), interpolation="bilinear")

<tf.Tensor: shape=(3, 3), dtype=float64, numpy=
array([[0.58578646, 1.        , 0.58578634],
       [1.        , 1.        , 1.        ],
       [0.58578646, 1.        , 0.58578634]])>

Other info / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions