Resize

Function Usage

Image resizing API of the ImageProcessor class. Atlas inference product and Atlas 800I A2 inference product support asynchronous execution. The Image memory allocated using this API does not need to be managed by the user and is released internally. For details about the resizing effect, see Figure 1.

For details, see Resizing.

Figure 1 Resizing

Prototype

1
APP_ERROR ImageProcessor::Resize(const Image& inputImage, const Size& resize, Image& outputImage, const Interpolation interpolation, AscendStream& stream = AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

inputImage

Input

Image class before resizing. The Image class obtained by the Decode API and other VPC APIs can be directly used as inputs. If the user-defined Image class is used, set the original and aligned image widths and heights.

resize

Input

Height and width for resizing

interpolation

Input

Resizing mode of an input image:

1
2
3
4
5
HUAWEI_HIGH_ORDER_FILTER = 0
BILINEAR_SIMILAR_OPENCV = 1
NEAREST_NEIGHBOR_OPENCV = 2
BILINEAR_SIMILAR_TENSORFLOW = 3
NEAREST_NEIGHBOR_TENSORFLOW = 4
The following algorithms are supported by the Atlas 200/300/500 inference product :
  • 0 (default): Huawei-developed high-order filtering algorithm.
  • 1: conventional bilinear algorithm, whose compute accuracy is close to that of OpenCV.
  • 2: conventional nearest neighbor algorithm, whose compute accuracy is close to that of OpenCV.
  • 3: conventional bilinear algorithm, whose compute accuracy is close to that of TensorFlow.
  • 4: conventional nearest neighbor algorithm, whose compute accuracy is close to that of TensorFlow.
The following algorithms are supported by the Atlas 200I/500 A2 inference product :
  • 0 (default): Huawei-developed high-order filtering algorithm.
  • 1: conventional bilinear algorithm, whose compute accuracy is close to that of OpenCV.
  • 2: conventional nearest neighbor algorithm, whose compute accuracy is close to that of OpenCV.
  • 3: conventional bilinear algorithm, whose compute accuracy is close to that of TensorFlow.
  • 4: conventional nearest neighbor algorithm, whose compute accuracy is close to that of TensorFlow.
Atlas inference product and Atlas 800I A2 inference product support the following algorithms (defaulted to 0 during synchronous execution):
  • 0 and 1: conventional bilinear algorithm, whose compute process is similar to that of OpenCV. When the input and output images are both in RGB format and the resizing range is [1/32, 512], the maximum value difference of a single pixel from OpenCV is ±1.
  • 2: conventional nearest neighbor algorithm, whose compute process is close to that of OpenCV.

outputImage

Output

Image class after resizing

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.