Update imgproc_canny.cl

Reordering condition checking.
pull/1677/head
Peng Xiao 12 years ago
parent 6dda2652cd
commit 4b712eeded
  1. 19
      modules/ocl/src/opencl/imgproc_canny.cl

@ -505,17 +505,12 @@ edgesHysteresisGlobal
int map_offset
)
{
map_step /= sizeof(*map);
map_offset /= sizeof(*map);
map += map_offset;
int gidx = get_global_id(0);
int gidy = get_global_id(1);
int lidx = get_local_id(0);
int lidy = get_local_id(1);
int grp_idx = get_group_id(0);
int grp_idy = get_group_id(1);
@ -536,14 +531,11 @@ edgesHysteresisGlobal
if(ind < count)
{
ushort2 pos = st1[ind];
if (pos.x > 0 && pos.x <= cols && pos.y > 0 && pos.y <= rows)
{
if (lidx < 8)
{
pos.x += c_dx[lidx];
pos.y += c_dy[lidx];
if (map[pos.x + pos.y * map_step] == 1)
if (pos.x > 0 && pos.x <= cols && pos.y > 0 && pos.y <= rows && map[pos.x + pos.y * map_step] == 1)
{
map[pos.x + pos.y * map_step] = 2;
@ -559,22 +551,18 @@ edgesHysteresisGlobal
const int subTaskIdx = lidx >> 3;
const int portion = min(s_counter, (uint)(get_local_size(0)>> 3));
pos.x = pos.y = 0;
if (subTaskIdx < portion)
pos = s_st[s_counter - 1 - subTaskIdx];
barrier(CLK_LOCAL_MEM_FENCE);
if (lidx == 0)
s_counter -= portion;
barrier(CLK_LOCAL_MEM_FENCE);
if (pos.x > 0 && pos.x <= cols && pos.y > 0 && pos.y <= rows)
if (subTaskIdx < portion)
{
pos.x += c_dx[lidx & 7];
pos.y += c_dy[lidx & 7];
if (map[pos.x + pos.y * map_step] == 1)
if (pos.x > 0 && pos.x <= cols && pos.y > 0 && pos.y <= rows && map[pos.x + pos.y * map_step] == 1)
{
map[pos.x + pos.y * map_step] = 2;
@ -604,7 +592,6 @@ edgesHysteresisGlobal
}
}
}
}
#undef stack_size
//Get the edge result. egde type of value 2 will be marked as an edge point and set to 255. Otherwise 0.

Loading…
Cancel
Save