28 #define DATA_TYPE_MIN 0x0 32 #define DATA_TYPE_MAX 0xFF 37 __constant uint16
idx16 = (uint16)(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
56 __global
int *min_max,
68 uint width4 = width >> 4;
69 for(uint i = 0; i < width4; i++)
72 data = vload16(0, (__global DATA_TYPE *)
offset(&src, i << 4, 0));
73 local_min = min(data, local_min);
74 local_max = max(data, local_max);
77 #ifdef NON_MULTIPLE_OF_16 80 data = vload16(0, (__global DATA_TYPE *)
offset(&src, width4 << 4, 0));
83 local_max = max(local_max, select(
type_min, data, widx));
84 local_min = min(local_min, select(
type_max, data, widx));
88 local_min.s01234567 = min(local_min.s01234567, local_min.s89ABCDEF);
89 local_max.s01234567 = max(local_max.s01234567, local_max.s89ABCDEF);
91 local_min.s0123 = min(local_min.s0123, local_min.s4567);
92 local_max.s0123 = max(local_max.s0123, local_max.s4567);
94 local_min.s01 = min(local_min.s01, local_min.s23);
95 local_max.s01 = max(local_max.s01, local_max.s23);
97 local_min.s0 = min(local_min.s0, local_min.s1);
98 local_max.s0 = max(local_max.s0, local_max.s1);
101 atomic_min(&min_max[0], local_min.s0);
102 atomic_max(&min_max[1], local_max.s0);
125 __global
int *min_max,
126 __global uint *min_max_count
127 #
if defined LOCATE_MIN
131 #
if defined LOCATE_MAX
140 #if defined COUNT_MIN_MAX 141 if(value == min_max[0])
143 uint idx = atomic_inc(&min_max_count[0]);
144 #if defined LOCATE_MIN 145 if(idx < max_min_loc_count)
147 min_loc[idx].x = get_global_id(0);
148 min_loc[idx].y = get_global_id(1);
152 if(value == min_max[1])
154 uint idx = atomic_inc(&min_max_count[1]);
155 #if defined LOCATE_MAX 156 if(idx < max_max_loc_count)
158 max_loc[idx].x = get_global_id(0);
159 max_loc[idx].y = get_global_id(1);
#define IMAGE_DECLARATION(name)
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
#define CONVERT_TO_IMAGE_STRUCT(name)
#define VEC_DATA_TYPE(type, size)
__kernel void minmaxloc(__global uchar *src_ptr, uint src_stride_x, uint src_step_x, uint src_stride_y, uint src_step_y, uint src_offset_first_element_in_bytes, __global int *min_max, __global uint *min_max_count, __global Coordinates2D *min_loc, uint max_min_loc_count, __global Coordinates2D *max_loc, uint max_max_loc_count)
This function counts the min and max occurrences in an image and tags their position.
Structure to hold Image information.
__constant DATA_TYPE16 type_min
__global uchar * ptr
Pointer to the starting postion of the buffer.
__constant DATA_TYPE16 type_max
__kernel void minmax(__global uchar *src_ptr, uint src_stride_x, uint src_step_x, uint src_stride_y, uint src_step_y, uint src_offset_first_element_in_bytes, __global int *min_max, uint width)
This function identifies the min and maximum value of an input image.