47 return CONVERT_SAT((sqrt(convert_float16((convert_uint16(a * a) + convert_uint16(b * b)))) + 0.5f),
60 float16 angle_deg_f32 = atan2pi(convert_float16(
b), convert_float16(a)) * (float16)180.0f;
61 angle_deg_f32 =
select(angle_deg_f32, (float16)180.0f + angle_deg_f32, angle_deg_f32 < (float16)0.0f);
62 return convert_uchar16(angle_deg_f32);
74 float16 arct = atan2pi(convert_float16(
b), convert_float16(a));
75 arct =
select(arct, arct + 2, arct < 0.0f);
77 return convert_uchar16(convert_int16(mad(arct, 128, 0.5f)) & (int16)0xFFu);
81 #define MAGNITUDE_OP(x, y) magnitude_l1((x), (y)) 83 #define MAGNITUDE_OP(x, y) magnitude_l2(convert_int16(x), convert_int16(y)) 85 #define MAGNITUDE_OP(x, y) 89 #define PHASE_OP(x, y) phase_unsigned((x), (y)) 91 #define PHASE_OP(x, y) phase_signed((x), (y)) 93 #define PHASE_OP(x, y) #define CONVERT_TO_IMAGE_STRUCT(name)
#define IMAGE_DECLARATION(name)
SimpleTensor< uint8_t > phase(const SimpleTensor< T > &gx, const SimpleTensor< T > &gy, PhaseType phase_type)
#define CONVERT_SAT(a, b)
uchar16 phase_signed(DATA_TYPE16 a, DATA_TYPE16 b)
Calculates signed phase between two inputs.
DATA_TYPE16 magnitude_l2(int16 a, int16 b)
Calculates L2 normalization between two inputs.
uchar16 phase_unsigned(DATA_TYPE16 a, DATA_TYPE16 b)
Calculates unsigned phase between two inputs.
uint8_t add_sat(const uint8_t &a, const uint8_t &b)
Structure to hold Image information.
__global uchar * ptr
Pointer to the starting postion of the buffer.
SimpleTensor< T > select(const SimpleTensor< uint8_t > &c, const SimpleTensor< T > &x, const SimpleTensor< T > &y)
__kernel void magnitude_phase(__global uchar *gx_ptr, uint gx_stride_x, uint gx_step_x, uint gx_stride_y, uint gx_step_y, uint gx_offset_first_element_in_bytes, __global uchar *gy_ptr, uint gy_stride_x, uint gy_step_x, uint gy_stride_y, uint gy_step_y, uint gy_offset_first_element_in_bytes, __global uchar *magnitude_ptr, uint magnitude_stride_x, uint magnitude_step_x, uint magnitude_stride_y, uint magnitude_step_y, uint magnitude_offset_first_element_in_bytes, __global uchar *phase_ptr, uint phase_stride_x, uint phase_step_x, uint phase_stride_y, uint phase_step_y, uint phase_offset_first_element_in_bytes)
Calculate the magnitude and phase of given the gradients of an image.
SimpleTensor< T > magnitude(const SimpleTensor< T > &gx, const SimpleTensor< T > &gy, MagnitudeType magnitude_type)
#define MAGNITUDE_OP(x, y)
DATA_TYPE16 magnitude_l1(DATA_TYPE16 a, DATA_TYPE16 b)
Calculates L1 normalization between two inputs.
#define VEC_DATA_TYPE(type, size)