24 #ifndef SRC_CORE_HELPERS_SCALEHELPERS_H 25 #define SRC_CORE_HELPERS_SCALEHELPERS_H 37 namespace scale_helpers
58 const float dx1 = 1.0f - dx;
59 const float dy1 = 1.0f - dy;
66 const float w1 = dx1 * dy1;
67 const float w2 = dx * dy1;
68 const float w3 = dx1 * dy;
69 const float w4 = dx * dy;
70 float res = a00 * w1 + a01 * w2 + a10 * w3 + a11 * w4;
93 const float dx1 = 1.0f - dx;
94 const float dy1 = 1.0f - dy;
101 const float w1 = dx1 * dy1;
102 const float w2 = dx * dy1;
103 const float w3 = dx1 * dy;
104 const float w4 = dx * dy;
105 float res = a00 * w1 + a01 * w2 + a10 * w3 + a11 * w4;
127 float hr,
int x,
int y)
132 float in_x = (x + 0.5f) * wr - 0.5f;
133 float in_y = (y + 0.5f) * hr - 0.5f;
136 int x_from = std::floor(x * wr - 0.5f - in_x);
137 int y_from = std::floor(y * hr - 0.5f - in_y);
138 int x_to = std::ceil((x + 1) * wr - 0.5f - in_x);
139 int y_to = std::ceil((y + 1) * hr - 0.5f - in_y);
142 in_x = std::max(-1.f, std::min(in_x, static_cast<float>(width)));
143 in_y = std::max(-1.f, std::min(in_y, static_cast<float>(height)));
146 x_from = ((in_x + x_from) < -1) ? -1 : x_from;
147 y_from = ((in_y + y_from) < -1) ? -1 : y_from;
148 x_to = ((in_x + x_to) > width) ? (width - in_x) : x_to;
149 y_to = ((in_y + y_to) > height) ? (height - in_y) : y_to;
152 const int xi = std::floor(in_x);
153 const int yi = std::floor(in_y);
156 const int x_elements = (x_to - x_from + 1);
157 const int y_elements = (y_to - y_from + 1);
162 for(
int j = yi + y_from, je = yi + y_to; j <= je; ++j)
164 const uint8_t *ptr = first_pixel_ptr + j * stride + xi + x_from;
169 return sum / (x_elements * y_elements);
186 inline float delta_bilinear(
float a00,
float a01,
float a10,
float a11,
float dx_val,
float dy_val)
188 const float dx1_val = 1.0f - dx_val;
189 const float dy1_val = 1.0f - dy_val;
191 const float w1 = dx1_val * dy1_val;
192 const float w2 = dx_val * dy1_val;
193 const float w3 = dx1_val * dy_val;
194 const float w4 = dx_val * dy_val;
195 return a00 * w1 + a01 * w2 + a10 * w3 + a11 * w4;
uint8_t delta_bilinear_c1_quantized(const uint8_t *pixel_ptr, size_t stride, float dx, float dy, UniformQuantizationInfo iq_info, UniformQuantizationInfo oq_info)
Computes bilinear interpolation for quantized input and output, using the pointer to the top-left pix...
float dequantize_qasymm8(uint8_t value, const INFO_TYPE &qinfo)
Dequantize a value given an unsigned 8-bit asymmetric quantization scheme.
uint8_t quantize_qasymm8(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given an unsigned 8-bit asymmetric quantization scheme.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
SimpleTensor< T2 > accumulate(const SimpleTensor< T1 > &src, DataType output_data_type)
Copyright (c) 2017-2021 Arm Limited.
int8_t quantize_qasymm8_signed(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a signed 8-bit asymmetric quantization scheme.
uint8_t pixel_area_c1u8_clamp(const uint8_t *first_pixel_ptr, size_t stride, size_t width, size_t height, float wr, float hr, int x, int y)
Return the pixel at (x,y) using area interpolation by clamping when out of borders.
float dequantize_qasymm8_signed(int8_t value, const INFO_TYPE &qinfo)
Dequantize a value given a signed 8-bit asymmetric quantization scheme.
float delta_bilinear(float a00, float a01, float a10, float a11, float dx_val, float dy_val)
Computes bilinear interpolation using the top-left, top-right, bottom-left, bottom-right pixels and t...