Threshold
Function Usage
Tensor thresholding API for image processing. The supported data types are float16, float32, and uint8. Asynchronous calling is supported. The inplace operation is not supported.
It is supported by the Atlas inference product and
For the
The following conditions must be met:
- The input and output tensors must be on the device or DVPP, and the parameters (stream and data memory) must be on the same device.
- For synchronization, the device where the data memory is located must be the same as the initialized device.
- Handle the issue of out-of-range data if any.
- For the Atlas inference product, this API is used for saturation computation. When the data value is out of the range of the data type, data wrapping does not occur. For the
Atlas 200I/500 A2 inference product , this API is used for non-saturation computation. - The input and output parameters cannot exceed four dimensions, and must match the tensor shapes and types.
Prototype
1 | APP_ERROR Threshold(const Tensor &src, Tensor &dst, float thresh, float maxVal, const ThresholdType &thresholdType = ThresholdType::THRESHOLD_BINARY, AscendStream &stream = AscendStream::DefaultStream()); |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
src |
Input |
Tensor class, input tensor, supporting the float16, float32, and uint8 data types. The data memory must be on the device or DVPP. |
dst |
Output |
Tensor class, output tensor, supporting the float16, float32, and uint8 data types. An empty tensor can be passed. If dst is not empty, the shape of dst must be the same as that of src. Call Tensor.Malloc() to allocate memory in advance. The data memory must be on the device (the same device as that of src) or DVPP. |
thresh |
Input |
Float type. It specifies the src threshold to be compared. |
maxVal |
Input |
Float type. It specifies the value that meets the condition after src is compared with thresh. |
thresholdType |
Input |
Enumeration type of ThresholdType, which indicates the specific rule for thresholding. Currently, binarization and inverse binarization are supported. The binarization (dst = maxVal (src>thresh) or 0 (src<= thresh)) is used by default. The inverse binarization is supported only by the Atlas inference product. |
stream |
Input |
AscendStream type. The default value is AscendStream::DefaultStream(). When the parameter value is the default value, the API calling is a synchronous operation. In other cases, the API calling is an asynchronous operation. |
Response Parameters
Data Structure |
Description |
|---|---|
APP_ERROR |
For details about the returned error codes, see APP_ERROR Description. |