# tfg.image.transformer.sample

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/image/transformer.py#L44-L108) |

Samples an image at user defined coordinates.

    tfg.image.transformer.sample(
        image: type_alias.TensorLike,
        warp: type_alias.TensorLike,
        resampling_type: https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/ResamplingType = https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/ResamplingType#BILINEAR,
        border_type: https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/BorderType = https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/BorderType#ZERO,
        pixel_type: https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/PixelType = https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/PixelType#HALF_INTEGER,
        name: Optional[str] = 'sample'
    ) -> tf.Tensor

<br />

<br />

<br />

| ## Note ||
|---|---|
| The warp maps target to source. In the following, A1 to An are optional batch dimensions. ||

<br />

<br />

| ## Args ||
|---|---|
| image: A tensor of shape `[B, H_i, W_i, C]`, where `B` is the batch size, `H_i` the height of the image, `W_i` the width of the image, and `C` the number of channels of the image. warp: A tensor of shape `[B, A_1, ..., A_n, 2]` containing the x and y coordinates at which sampling will be performed. The last dimension must be 2, representing the (x, y) coordinate where x is the index for width and y is the index for height. ||
| `resampling_type` | Resampling mode. Supported values are [`ResamplingType.NEAREST`](https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/ResamplingType#NEAREST) and [`ResamplingType.BILINEAR`](https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/ResamplingType#BILINEAR). border_type: Border mode. Supported values are [`BorderType.ZERO`](https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/BorderType#ZERO) and [`BorderType.DUPLICATE`](https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/BorderType#DUPLICATE). pixel_type: Pixel mode. Supported values are [`PixelType.INTEGER`](https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/PixelType#INTEGER) and [`PixelType.HALF_INTEGER`](https://www.tensorflow.org/graphics/api_docs/python/tfg/image/transformer/PixelType#HALF_INTEGER). name: A name for this op. Defaults to "sample". |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| Tensor of sampled values from `image`. The output tensor shape is `[B, A_1, ..., A_n, C]`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `image` has rank != 4. If `warp` has rank \< 2 or its last dimension is not 2. If `image` and `warp` batch dimension does not match. |

<br />