Commit d743a4c9 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #9506 from alalek:ocl_fix_canny_ub_9496

parents 02d98d32 e3b12bdb
...@@ -221,11 +221,11 @@ __kernel void stage1_with_sobel(__global const uchar *src, int src_step, int src ...@@ -221,11 +221,11 @@ __kernel void stage1_with_sobel(__global const uchar *src, int src_step, int src
int value = 1; int value = 1;
if (mag0 > low_thr) if (mag0 > low_thr)
{ {
int a = (y / (float)x) * TG22; float x_ = abs(x);
int b = (y / (float)x) * TG67; float y_ = abs(y);
a = min((int)abs(a), 1) + 1; int a = (y_ * TG22 >= x_) ? 2 : 1;
b = min((int)abs(b), 1); int b = (y_ * TG67 >= x_) ? 1 : 0;
// a = { 1, 2 } // a = { 1, 2 }
// b = { 0, 1 } // b = { 0, 1 }
...@@ -342,11 +342,11 @@ __kernel void stage1_without_sobel(__global const uchar *dxptr, int dx_step, int ...@@ -342,11 +342,11 @@ __kernel void stage1_without_sobel(__global const uchar *dxptr, int dx_step, int
int value = 1; int value = 1;
if (mag0 > low_thr) if (mag0 > low_thr)
{ {
int a = (y / (float)x) * TG22; float x_ = abs(x);
int b = (y / (float)x) * TG67; float y_ = abs(y);
a = min((int)abs(a), 1) + 1; int a = (y_ * TG22 >= x_) ? 2 : 1;
b = min((int)abs(b), 1); int b = (y_ * TG67 >= x_) ? 1 : 0;
int dir3 = (a * b) & (((x ^ y) & 0x80000000) >> 31); int dir3 = (a * b) & (((x ^ y) & 0x80000000) >> 31);
int dir = a * b + 2 * dir3; int dir = a * b + 2 * dir3;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment