Skip to content

Logic behind shear_* and translate_* #1724

@WindQAQ

Description

@WindQAQ

Currently, shear_* and translate_* do wrap before transformation and unwrap after transformation. I am confused why we have to do these. Usually, when talking about shearing and translation, it is just a kind of affine transformation without doing these things.

I suppose that we previously implemented in that way is because our transform cannot select the extend mode/filling value. So we have to append an additional channel (wrap) before transformation, and check the zeros in that channel after transformation in order to replace the filling value to desired one (unwrap). Once #1721 gets merged, we could revamp the design/API.

The implementation of translate_xy is also confusing. Apart from wrap and unwrap, shouldn't translate_xy(x, [dx, dy]) is equivalent to translate(x, [dx, dy]) if replace is zero? So I think we can deprecate translate_xy after #1721 gets merged. Besides, translating [dx, 0] and then translating [0, dy] should be logically equivalent to translating [dx, dy] together unless there is some coordinate rounding issue when warping the image.
https://github.com/tensorflow/addons/blob/master/tensorflow_addons/image/translate_ops.py#L124-L125

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions