acldvppAutoContrast

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Description

Remaps the pixels of each channel to maximize the contrast. The darkest pixel in the image is mapped to black, and the brightest pixel is mapped to white. In addition, you can adjust the cutoff and ignore parameters to control the contrast.

Prototype

Each operator has two-phase API calls. First, acldvppAutoContrastGetWorkspaceSize is called to calculate the required workspace size based on the computation process. Then, acldvppAutoContrast is called to perform computation. The two-phase APIs are as follows:

  • First-phase API:
    1
    acldvppStatus acldvppAutoContrastGetWorkspaceSize(const aclTensor *self, const aclFloatArray *cutoff, const aclIntArray *ignore, aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor)
    
  • Second-phase API:
    1
    acldvppStatus acldvppAutoContrast(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream)
    

acldvppAutoContrastGetWorkspaceSize

  • Parameters:
    • self: input tensor of the operator. Call aclCreateTensor to create data of the aclTensor type (stored on the device). The data type of the input tensor can be UINT8 or FLOAT, and the format can be NCHW or NHWC. Discontinuous tensors are not supported, in addition, N can be 1 or empty, and C can be 1 or 3. (1 indicates that the input data is in GRAY format, and 3 indicates that the input data is in the sequence of R, G, and B.) When data type is set to FLOAT, the expected value range is [0, 1].
    • cutoff: percentage of the darkest and brightest pixels to be removed from the input image histogram. Call aclCreateFloatArray to create data of the aclFloatArray type. The length is 2. The first number indicates the darkest, and the second number indicates the brightest. The data value must be within the range of [0.0, 50.0). If a null pointer is passed, the two percentages are set to the default value 0.0.
    • ignore: background pixel value to be ignored in the input image histogram. aclCreateIntArray needs to be called to create data of the aclIntArray type. The data length is less than or equal to 256, and the data value must be within the range of [0, 255]. If a null pointer is passed, the pixel value is not ignored by default.
    • out: output tensor of the operator. aclCreateTensor needs to be called to create data of the aclTensor type (stored on the device). The data type of the output tensor can be UINT8 or FLOAT, but cannot be non-contiguous tensors, the values of Format and Shape must be the same as those of self.
    • workspaceSize: size of the workspace to be allocated on the device.
    • executor: operator executor, containing the operator computation process.
  • Returns:

    The status code acldvppStatus is returned. For details, see acldvpp Return Codes.

acldvppAutoContrast

  • Parameters:
    • workspace: The aclrtMalloc API needs to be called to allocate the device memory. The memory size is workspaceSize. The memory address output by the aclrtMalloc API is passed here.
    • workspaceSize: The value must be the same as that obtained by calling acldvppAutoContrastGetWorkspaceSize.
    • executor: op executor, which contains the operator computation process and is the same as the executor of the acldvppAutoContrastGetWorkspaceSize API.
    • stream: stream for executing the task. You can reuse the created stream to save resources or call aclrtCreateStream to create a stream, and then pass the stream as an input parameter.
  • Returns

    The status code acldvppStatus is returned. For details, see acldvpp Return Codes.

Constraints

The supported image resolution ranges from 6 x 4 to 4096 x 8192.

If dataType is set to UINT8, the result is the same as that of Torchvision. If dataType is set to FLOAT, the maximum difference between the result and Torchvision is +-1/255.