1# Copyright 2019 Huawei Technologies Co., Ltd 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14""" 15Interpolation Mode, Resampling Filters 16""" 17from enum import Enum, IntEnum 18 19 20class Inter(IntEnum): 21 """ 22 Interpolation Modes. 23 24 Possible enumeration values are: Inter.NEAREST, Inter.ANTIALIAS, Inter.LINEAR, Inter.BILINEAR, Inter.CUBIC, 25 Inter.BICUBIC, Inter.AREA, Inter.PILCUBIC. 26 27 - Inter.NEAREST: means interpolation method is nearest-neighbor interpolation. 28 - Inter.ANTIALIAS: means the interpolation method is antialias interpolation. 29 - Inter.LINEAR: means interpolation method is bilinear interpolation, here is the same as Inter.BILINEAR. 30 - Inter.BILINEAR: means interpolation method is bilinear interpolation. 31 - Inter.CUBIC: means the interpolation method is bicubic interpolation, here is the same as Inter.BICUBIC. 32 - Inter.BICUBIC: means the interpolation method is bicubic interpolation. 33 - Inter.AREA: means interpolation method is pixel area interpolation. 34 - Inter.PILCUBIC: means interpolation method is bicubic interpolation like implemented in pillow, input 35 should be in 3 channels format. 36 """ 37 NEAREST = 0 38 ANTIALIAS = 1 39 BILINEAR = LINEAR = 2 40 BICUBIC = CUBIC = 3 41 AREA = 4 42 PILCUBIC = 5 43 44 45class Border(str, Enum): 46 """ 47 Padding Mode, Border Type. 48 49 Possible enumeration values are: Border.CONSTANT, Border.EDGE, Border.REFLECT, Border.SYMMETRIC. 50 51 - Border.CONSTANT: means it fills the border with constant values. 52 - Border.EDGE: means it pads with the last value on the edge. 53 - Border.REFLECT: means it reflects the values on the edge omitting the last value of edge. 54 - Border.SYMMETRIC: means it reflects the values on the edge repeating the last value of edge. 55 56 Note: This class derived from class str to support json serializable. 57 """ 58 CONSTANT: str = "constant" 59 EDGE: str = "edge" 60 REFLECT: str = "reflect" 61 SYMMETRIC: str = "symmetric" 62 63 64class ImageBatchFormat(IntEnum): 65 """ 66 Data Format of images after batch operation. 67 68 Possible enumeration values are: ImageBatchFormat.NHWC, ImageBatchFormat.NCHW. 69 70 - ImageBatchFormat.NHWC: in orders like, batch N, height H, width W, channels C to store the data. 71 - ImageBatchFormat.NCHW: in orders like, batch N, channels C, height H, width W to store the data. 72 """ 73 NHWC = 0 74 NCHW = 1 75 76 77class ConvertMode(IntEnum): 78 """The color conversion code""" 79 COLOR_BGR2BGRA = 0 80 COLOR_RGB2RGBA = COLOR_BGR2BGRA 81 COLOR_BGRA2BGR = 1 82 COLOR_RGBA2RGB = COLOR_BGRA2BGR 83 COLOR_BGR2RGBA = 2 84 COLOR_RGB2BGRA = COLOR_BGR2RGBA 85 COLOR_RGBA2BGR = 3 86 COLOR_BGRA2RGB = COLOR_RGBA2BGR 87 COLOR_BGR2RGB = 4 88 COLOR_RGB2BGR = COLOR_BGR2RGB 89 COLOR_BGRA2RGBA = 5 90 COLOR_RGBA2BGRA = COLOR_BGRA2RGBA 91 COLOR_BGR2GRAY = 6 92 COLOR_RGB2GRAY = 7 93 COLOR_GRAY2BGR = 8 94 COLOR_GRAY2RGB = COLOR_GRAY2BGR 95 COLOR_GRAY2BGRA = 9 96 COLOR_GRAY2RGBA = COLOR_GRAY2BGRA 97 COLOR_BGRA2GRAY = 10 98 COLOR_RGBA2GRAY = 11 99 100 101class SliceMode(IntEnum): 102 """ 103 Mode to Slice Tensor into multiple parts. 104 105 Possible enumeration values are: SliceMode.PAD, SliceMode.DROP. 106 107 - SliceMode.PAD: pad some pixels before slice the Tensor if needed. 108 - SliceMode.DROP: drop remainder pixels before slice the Tensor if needed. 109 """ 110 PAD = 0 111 DROP = 1 112