[gegl] sobel: Bring OpenCL implementation closer to the C one
- From: Mukund Sivaraman <muks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] sobel: Bring OpenCL implementation closer to the C one
- Date: Thu, 9 Oct 2014 10:46:28 +0000 (UTC)
commit 8feb4eb0f2e19bbace2e5e6fd348dd44b168d7aa
Author: Mukund Sivaraman <muks banu com>
Date: Thu Oct 9 16:16:01 2014 +0530
sobel: Bring OpenCL implementation closer to the C one
There is still the case of removing the sobel radius and access out
of rect bounds.
opencl/edge-sobel.cl | 17 ++++++++---------
opencl/edge-sobel.cl.h | 17 ++++++++---------
2 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/opencl/edge-sobel.cl b/opencl/edge-sobel.cl
index c41a290..f6ca9d1 100644
--- a/opencl/edge-sobel.cl
+++ b/opencl/edge-sobel.cl
@@ -32,23 +32,22 @@ kernel void kernel_edgesobel(global float4 *in,
if (horizontal)
{
hor_grad +=
- - 1.0f * pix_fl + 1.0f * pix_fr
- - 2.0f * pix_ml + 2.0f * pix_mr
- - 1.0f * pix_bl + 1.0f * pix_br;
+ (-1.0f * pix_fl + 1.0f * pix_fr) +
+ (-2.0f * pix_ml + 2.0f * pix_mr) +
+ (-1.0f * pix_bl + 1.0f * pix_br);
}
if (vertical)
{
ver_grad +=
- - 1.0f * pix_fl - 2.0f * pix_fm
- - 1.0f * pix_fr + 1.0f * pix_bl
- + 2.0f * pix_bm + 1.0f * pix_br;
+ ( 1.0f * pix_fl) + ( 2.0f * pix_fm) + ( 1.0f * pix_fr) +
+ (-1.0f * pix_bl) + (-2.0f * pix_bm) + (-1.0f * pix_br);
}
if (horizontal && vertical)
{
- gradient = sqrt(
- hor_grad * hor_grad +
- ver_grad * ver_grad) / 1.41f;
+ /* sqrt(32.0) = 5.656854249492381 */
+ gradient = sqrt(hor_grad * hor_grad +
+ ver_grad * ver_grad) / 5.656854249492381;
}
else
{
diff --git a/opencl/edge-sobel.cl.h b/opencl/edge-sobel.cl.h
index 2dc5b0c..5f6fe7c 100644
--- a/opencl/edge-sobel.cl.h
+++ b/opencl/edge-sobel.cl.h
@@ -33,23 +33,22 @@ static const char* edge_sobel_cl_source =
" if (horizontal) \n"
" { \n"
" hor_grad += \n"
-" - 1.0f * pix_fl + 1.0f * pix_fr \n"
-" - 2.0f * pix_ml + 2.0f * pix_mr \n"
-" - 1.0f * pix_bl + 1.0f * pix_br; \n"
+" (-1.0f * pix_fl + 1.0f * pix_fr) + \n"
+" (-2.0f * pix_ml + 2.0f * pix_mr) + \n"
+" (-1.0f * pix_bl + 1.0f * pix_br); \n"
" } \n"
" if (vertical) \n"
" { \n"
" ver_grad += \n"
-" - 1.0f * pix_fl - 2.0f * pix_fm \n"
-" - 1.0f * pix_fr + 1.0f * pix_bl \n"
-" + 2.0f * pix_bm + 1.0f * pix_br; \n"
+" ( 1.0f * pix_fl) + ( 2.0f * pix_fm) + ( 1.0f * pix_fr) + \n"
+" (-1.0f * pix_bl) + (-2.0f * pix_bm) + (-1.0f * pix_br); \n"
" } \n"
" \n"
" if (horizontal && vertical) \n"
" { \n"
-" gradient = sqrt( \n"
-" hor_grad * hor_grad + \n"
-" ver_grad * ver_grad) / 1.41f; \n"
+" /* sqrt(32.0) = 5.656854249492381 */ \n"
+" gradient = sqrt(hor_grad * hor_grad + \n"
+" ver_grad * ver_grad) / 5.656854249492381; \n"
" } \n"
" else \n"
" { \n"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]