DistanceTransform#

Functions#

NVCVStatus pvaDistanceTransformCreate(NVCVOperatorHandle *handle, NVCVTensorRequirements *tensorRequirements, PVADistanceType distanceType)

Constructs an instance of the DistanceTransform operator.

NVCVStatus pvaDistanceTransformSubmit(NVCVOperatorHandle handle, cupvaStream_t stream, const NVCVTensorHandle inImage, uint16_t maxDistance, NVCVTensorHandle outDistance, NVCVTensorHandle outLabel)

Executes the DistanceTransform operation.

Functions#

NVCVStatus pvaDistanceTransformCreate(
NVCVOperatorHandle *handle,
NVCVTensorRequirements *tensorRequirements,
PVADistanceType distanceType,
)#

Constructs an instance of the DistanceTransform operator.

The operator computes the minimum distance of each off-pixel in a binary image to the nearest on pixel. It is commonly used in object segmentation, shape analysis, and skeletonization.

Limitations:

Input: Apply to the inImage parameter of the pvaDistanceTransformSubmit. Data Layout: [kHWC] Channels: [1]

Data Type

Allowed

8bit Unsigned

No

8bit Signed

No

16bit Unsigned

Yes

16bit Signed

No

32bit Unsigned

No

32bit Signed

No

32bit Float

No

64bit Float

No

Output: Apply to the outDistance and outLabel parameters of the pvaDistanceTransformSubmit. Data Layout: [kHWC] Channels: [1]

Data Type

Allowed

8bit Unsigned

No

8bit Signed

No

16bit Unsigned

Yes

16bit Signed

No

32bit Unsigned

No

32bit Signed

No

32bit Float

No

64bit Float

No

Input/Output Dependency:

Property

Input == Output

Data Layout

Yes

Data Type

Yes

Number

Yes

Channels

Yes

Width

Yes

Height

Yes

Width/Height: Any value from 32 to 1024

Number of labels: Up to 16 labels valued from 0 to 15

Parameters:
  • handle[out] Where the operator instance handle will be written to.

    • Must not be NULL.

  • tensorRequirements[in] Pointer to the NVCVTensorRequirements structure which contains input image tensor rank, shape, layout and data type information.

  • distanceType[in] Type of distance that the operation computes. PVADistanceType. Current implementation only supports Euclidean distance. The distance value is in UQ13.3 fixed-point format.

Return values:
  • NVCV_ERROR_NOT_IMPLEMENTED – The distance type is not implementated.

  • 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 pvaDistanceTransformSubmit(
NVCVOperatorHandle handle,
cupvaStream_t stream,
const NVCVTensorHandle inImage,
uint16_t maxDistance,
NVCVTensorHandle outDistance,
NVCVTensorHandle outLabel,
)#

Executes the DistanceTransform operation.

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

    • Must not be NULL.

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

  • inImage[in] Input image with tensor handle. The image contains pixel label values in uint16 format. Pixels that are off (not labeled) should be set to 0xFFFF. Label values between 0 and 15 (inclusive) denote active pixels in the image. The caller must ensure input labels fall within this supported range. Labels outside this range will be ignored and produce undefined results.

  • maxDistance[in] The max distance of the operator in the fixed-point format of UQ13.3. Any distance greater is saturated to this value. The max distance should be in the range from 0.0 to (image_width + image_height).0. Setting to 0.0 means using the default value (image_width + image_height).0 (need to convert to UQ13.3 format by left shifting 3 bits).

  • outDistance[out] Output distance tensor handle. The distance from off pixel to the nearest on pixel is notated as UQ13.3.

  • outLabel[out] Output label tensor handle. The label value of each pixel marks the Voronoi regions.

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

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

  • NVCV_SUCCESS – Operation executed successfully.