Remap

group NVCV_C_ALGORITHM_REMAP

Functions

NVCVStatus cvcudaRemapCreate(NVCVOperatorHandle *handle)

Constructs and an instance of the Remap operator.

Parameters:

handle[out] Where the image instance handle will be written to.

  • Must not be NULL.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Handle is null.

  • NVCV_ERROR_OUT_OF_MEMORY – Not enough memory to create the operator.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus cvcudaRemapSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle out, NVCVTensorHandle map, NVCVInterpolationType inInterp, NVCVInterpolationType mapInterp, NVCVRemapMapValueType mapValueType, int8_t alignCorners, NVCVBorderType border, float4 borderValue)

Executes the Remap operation on the given cuda stream. This operation does not wait for completion.

Remap operation writes in the output an element read in the input in a position determined by the map. First, the Remap operation reads a map value at each output coordinate. The map value is either an absolute position, denormalized (NVCV_REMAP_ABSOLUTE) or normalized (NVCV_REMAP_ABSOLUTE_NORMALIZED), (x, y) or it is a relative offset (NVCV_REMAP_RELATIVE_NORMALIZED) (dx, dy) from the normalized output coordinate to a normalized position in the input. The element at that input position is fetched from input and stored at the output position.

../_images/remap.svg

Limitations:

Input: Data Layout: [NVCV_TENSOR_NHWC, NVCV_TENSOR_HWC] Channels: [1, 3, 4]

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

No

16bit Unsigned

No

16bit Signed

No

32bit Unsigned

No

32bit Signed

No

32bit Float

Yes

64bit Float

No

Output: Data Layout: [NVCV_TENSOR_NHWC, NVCV_TENSOR_HWC] Channels: [1, 3, 4]

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

No

16bit Unsigned

No

16bit Signed

No

32bit Unsigned

No

32bit Signed

No

32bit Float

Yes

64bit Float

No

Input map: Data Layout: [NVCV_TENSOR_NHWC, NVCV_TENSOR_HWC] Channels: [2]

Data Type

Allowed

8bit Unsigned

No

8bit Signed

No

16bit Unsigned

No

16bit Signed

No

32bit Unsigned

No

32bit Signed

No

32bit Float

Yes

64bit Float

No

Input/Output dependency

 Property      |  Input == Output
-------------- | -------------
 Data Layout   | Yes
 Data Type     | Yes
 Channels      | Yes
 Width         | No
 Height        | No
 Samples       | Yes
Input/Map dependency
 Property      |  Input == Map
-------------- | -------------
 Data Layout   | No
 Data Type     | No
 Channels      | No
 Width         | No
 Height        | No
 Samples       | Yes or 1

Parameters:
  • handle[in] Handle to the operator.

    • Must not be NULL.

  • stream[in] Handle to a valid CUDA stream.

  • in[in] Input tensor to get values from.

    • Must not be NULL.

  • out[out] Output tensor to set values to.

    • Must not be NULL.

  • map[in] Input tensor to get {x, y} (float2) absolute positions (either normalized or not) or relative differences to map values from input to output. For each normalized position in the output, the map is read to get the map value used to fetch values from the input tensor and store them at that normalized position. The map value interpretation depends on mapValueType. The input, output and map tensors can have different width and height, but the input and output tensors must have the same number of samples. The number of samples of the map can be either equal to the input or one. In case it is one, the same map is applied to all input samples.

    • Must have float2 (2F32) data type.

    • Must not be NULL.

  • inInterp[in] Interpolation type to be used when fetching values from input tensor.

    • It may be one of the following interpolation types:

      • NVCV_INTERP_NEAREST

      • NVCV_INTERP_LINEAR

      • NVCV_INTERP_CUBIC

  • mapInterp[in] Interpolation type to be used when fetching indices from map tensor.

    • It may be one of the following interpolation types:

      • NVCV_INTERP_NEAREST

      • NVCV_INTERP_LINEAR

      • NVCV_INTERP_CUBIC

  • mapValueType[in] This determines how the values inside the map are interpreted. If it is NVCV_REMAP_ABSOLUTE the map values are absolute, denormalized positions in the input tensor to fetch values from. If it is NVCV_REMAP_ABSOLUTE_NORMALIZED the map values are absolute, normalized positions in [-1, 1] range to fetch values from the input tensor resolution agnostic. If it is NVCV_REMAP_RELATIVE_NORMALIZED the map values are relative, normalized offsets to be applied to each output position to fetch values from the input tensor, also resolution agnostic.

  • alignCorners[in] The remap operation from output to input via the map is done in floating-point domain. Set this flag to true so that they are aligned by the center points of their corner pixels. Set it to false so that they are aligned by the corner points of their corner pixels.

  • border[in] Border type to be used when fetching values from input tensor.

    • It may be one of the following border types:

      • NVCV_BORDER_CONSTANT

      • NVCV_BORDER_REPLICATE

      • NVCV_BORDER_REFLECT

      • NVCV_BORDER_WRAP

      • NVCV_BORDER_REFLECT101

  • borderValue[in] Border value used when accessing outside values in input tensor for constant border.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.

  • NVCV_ERROR_INTERNAL – Internal error in the operator, invalid types passed in.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus cvcudaRemapVarShapeSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVImageBatchHandle in, NVCVImageBatchHandle out, NVCVTensorHandle map, NVCVInterpolationType inInterp, NVCVInterpolationType mapInterp, NVCVRemapMapValueType mapValueType, int8_t alignCorners, NVCVBorderType border, float4 borderValue)

Executes the Remap operation on a batch of images.

Apart from input and output image batches, all parameters are the same as cvcudaRemapSubmit.

Parameters:
  • in[in] Input image batch.

  • out[out] Output image batch.