Warning: This project is deprecated. TensorFlow Addons has stopped development,
The project will only be providing minimal maintenance releases until May 2024. See the full
announcement here or on
github.
tfa.image.translate
Stay organized with collections
Save and categorize content based on your preferences.
Translate image(s) by the passed vectors(s).
@tf.function
tfa.image.translate(
images: tfa.types.TensorLike
,
translations: tfa.types.TensorLike
,
interpolation: str = 'nearest',
fill_mode: str = 'constant',
name: Optional[str] = None,
fill_value: tfa.types.TensorLike
= 0.0
) -> tf.Tensor
Args |
images
|
A tensor of shape
(num_images, num_rows, num_columns, num_channels) (NHWC),
(num_rows, num_columns, num_channels) (HWC), or
(num_rows, num_columns) (HW). The rank must be statically known (the
shape is not TensorShape(None) ).
|
translations
|
A vector representing [dx, dy] or (if images has rank 4)
a matrix of length num_images, with a [dx, dy] vector for each image
in the batch.
|
interpolation
|
Interpolation mode. Supported values: "nearest",
"bilinear".
|
fill_mode
|
Points outside the boundaries of the input are filled according
to the given mode (one of {'constant', 'reflect', 'wrap', 'nearest'} ).
- reflect:
(d c b a | a b c d | d c b a)
The input is extended by reflecting about the edge of the last pixel.
- constant:
(k k k k | a b c d | k k k k)
The input is extended by filling all values beyond the edge with the
same constant value k = 0.
- wrap:
(a b c d | a b c d | a b c d)
The input is extended by wrapping around to the opposite edge.
- nearest:
(a a a a | a b c d | d d d d)
The input is extended by the nearest pixel.
|
fill_value
|
a float represents the value to be filled outside the
boundaries when fill_mode is "constant".
|
name
|
The name of the op.
|
Returns |
Image(s) with the same type and shape as images , translated by the
given vector(s). Empty space due to the translation will be filled with
zeros.
|
Raises |
TypeError
|
If images is an invalid type.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-05-25 UTC.
[null,null,["Last updated 2023-05-25 UTC."],[],[],null,["# tfa.image.translate\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/addons/blob/v0.20.0/tensorflow_addons/image/translate_ops.py#L73-L123) |\n\nTranslate image(s) by the passed vectors(s). \n\n @tf.function\n tfa.image.translate(\n images: ../../tfa/types/TensorLike,\n translations: ../../tfa/types/TensorLike,\n interpolation: str = 'nearest',\n fill_mode: str = 'constant',\n name: Optional[str] = None,\n fill_value: ../../tfa/types/TensorLike = 0.0\n ) -\u003e tf.Tensor\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `images` | A tensor of shape `(num_images, num_rows, num_columns, num_channels)` (NHWC), `(num_rows, num_columns, num_channels)` (HWC), or `(num_rows, num_columns)` (HW). The rank must be statically known (the shape is not `TensorShape(None)`). |\n| `translations` | A vector representing `[dx, dy]` or (if `images` has rank 4) a matrix of length num_images, with a `[dx, dy]` vector for each image in the batch. |\n| `interpolation` | Interpolation mode. Supported values: \"nearest\", \"bilinear\". |\n| `fill_mode` | Points outside the boundaries of the input are filled according to the given mode (one of `{'constant', 'reflect', 'wrap', 'nearest'}`). \u003cbr /\u003e - *reflect* : `(d c b a | a b c d | d c b a)` The input is extended by reflecting about the edge of the last pixel. - *constant* : `(k k k k | a b c d | k k k k)` The input is extended by filling all values beyond the edge with the same constant value k = 0. - *wrap* : `(a b c d | a b c d | a b c d)` The input is extended by wrapping around to the opposite edge. - *nearest* : `(a a a a | a b c d | d d d d)` The input is extended by the nearest pixel. |\n| `fill_value` | a float represents the value to be filled outside the boundaries when `fill_mode` is \"constant\". |\n| `name` | The name of the op. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| Image(s) with the same type and shape as `images`, translated by the given vector(s). Empty space due to the translation will be filled with zeros. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|---------------------------------|\n| `TypeError` | If `images` is an invalid type. |\n\n\u003cbr /\u003e"]]