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.
Apply a non-linear warp to the image, where the warp is specified by a
dense flow field of offset vectors that define the correspondences of
pixel values in the output image back to locations in the source image.
Specifically, the pixel value at output[b, j, i, c] is
images[b, j - flow[b, j, i, 0], i - flow[b, j, i, 1], c].
The locations specified by this formula do not necessarily map to an int
index. Therefore, the pixel value is obtained by bilinear
interpolation of the 4 nearest pixels around
(b, j - flow[b, j, i, 0], i - flow[b, j, i, 1]). For locations outside
of the image, we use the nearest pixel values at the image boundary.
Args
image
4-D float Tensor with shape [batch, height, width, channels].
flow
A 4-D float Tensor with shape [batch, height, width, 2].
name
A name for the operation (optional).
Note that image and flow can be of type tf.half, tf.float32, or
tf.float64, and do not necessarily have to be the same type.
Returns
A 4-D float Tensor with shape[batch, height, width, channels]
and same type as input image.
Raises
ValueError
if height < 2 or width < 2 or the inputs have the wrong
number of dimensions.
[null,null,["Last updated 2023-05-25 UTC."],[],[],null,["# tfa.image.dense_image_warp\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/addons/blob/v0.20.0/tensorflow_addons/image/dense_image_warp.py#L182-L245) |\n\nImage warping using per-pixel flow vectors. \n\n @tf.function\n tfa.image.dense_image_warp(\n image: ../../tfa/types/TensorLike,\n flow: ../../tfa/types/TensorLike,\n name: Optional[str] = None\n ) -\u003e tf.Tensor\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|------------------------------------------------------------------------------------------------|\n| - [TensorFlow Addons Image: Operations](https://www.tensorflow.org/addons/tutorials/image_ops) |\n\nApply a non-linear warp to the image, where the warp is specified by a\ndense flow field of offset vectors that define the correspondences of\npixel values in the output image back to locations in the source image.\nSpecifically, the pixel value at `output[b, j, i, c]` is\n`images[b, j - flow[b, j, i, 0], i - flow[b, j, i, 1], c]`.\n\nThe locations specified by this formula do not necessarily map to an int\nindex. Therefore, the pixel value is obtained by bilinear\ninterpolation of the 4 nearest pixels around\n`(b, j - flow[b, j, i, 0], i - flow[b, j, i, 1])`. For locations outside\nof the image, we use the nearest pixel values at the image boundary.\n| **Note:** The definition of the flow field above is different from that of optical flow. This function expects the negative forward flow from output image to source image. Given two images `I_1` and `I_2` and the optical flow `F_12` from `I_1` to `I_2`, the image `I_1` can be reconstructed by `I_1_rec = dense_image_warp(I_2, -F_12)`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `image` | 4-D float `Tensor` with shape `[batch, height, width, channels]`. |\n| `flow` | A 4-D float `Tensor` with shape `[batch, height, width, 2]`. |\n| `name` | A name for the operation (optional). \u003cbr /\u003e Note that image and flow can be of type [`tf.half`](https://www.tensorflow.org/api_docs/python/tf#half), [`tf.float32`](https://www.tensorflow.org/api_docs/python/tf#float32), or [`tf.float64`](https://www.tensorflow.org/api_docs/python/tf#float64), and do not necessarily have to be the same type. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A 4-D float `Tensor` with shape`[batch, height, width, channels]` and same type as input image. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|-----------------------------------------------------------------------------------|\n| `ValueError` | if `height \u003c 2` or `width \u003c 2` or the inputs have the wrong number of dimensions. |\n\n\u003cbr /\u003e"]]