Image
Function Usage
- Constructs an empty Image object.
- Converts the ndarray of NumPy on the host to an Image object.
Prototype
1 | Image() |
1 | Image(b: ndarray, format: image_format, imageSizeInfo: Tuple = DEFAULT_IMAGE_SIZE_INFO) |
Input Parameters
Parameter |
Type |
Description |
|---|---|---|
b |
ndarray |
Constructs the NumPy array of an image. The type of each element is np.uint8 and has three dimensions, indicating the height, width, and number of channels (HWC) of the image. |
format |
image_format |
Image color gamut format. The following color gamut types are supported:
The number of channels (C) in the b (input ndarray) shape must be the same as the color gamut type. The following describes the number of channels corresponding to each color gamut type.
|
imageSizeInfo |
Tuple(Size, Size) |
Combination of the valid width/height of the image and the aligned width/height. The valid width/height cannot exceed the aligned width/height. The height and width inputs are as follows: tuple (valid width/height, aligned width/height)
|
- Read the ndarray for image conversion from OpenCV. If it is in the WHC shape (width, height, number of channels), it needs to be transposed into HWC (height, width, number of channels) before construction.
- After a tensor obtained by calling get_tensor/to_tensor/get_original_tensor is converted into a ndarray, the shape of the tensor is NHWC (number, height, width, and channel) or NHW (number, height, and width). In this case, transpose the tensor format into HWC before construction.
Response Parameters
Image object
Parent topic: Image