Samples an image at user defined coordinates.
tfg.image.transformer.sample(
image: type_alias.TensorLike,
warp: type_alias.TensorLike,
resampling_type: tfg.image.transformer.ResamplingType
= tfg.image.transformer.ResamplingType.BILINEAR
,
border_type: tfg.image.transformer.BorderType
= tfg.image.transformer.BorderType.ZERO
,
pixel_type: tfg.image.transformer.PixelType
= tfg.image.transformer.PixelType.HALF_INTEGER
,
name: Optional[str] = 'sample'
) -> tf.Tensor
Note |
The warp maps target to source. In the following, A1 to An are optional
batch dimensions.
|
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 and ResamplingType.BILINEAR .
border_type: Border mode. Supported values are BorderType.ZERO and
BorderType.DUPLICATE .
pixel_type: Pixel mode. Supported values are PixelType.INTEGER and
PixelType.HALF_INTEGER .
name: A name for this op. Defaults to "sample".
|
Returns |
Tensor of sampled values from image . The output tensor shape
is [B, A_1, ..., A_n, C] .
|
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.
|