From 34135a85f36e16cd53f890f47cb8a778df43a720 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 26 Aug 2010 12:30:41 +0000 Subject: [PATCH] fixed 3 bytes reading/writing in remap --- modules/gpu/src/cuda/imgproc.cu | 48 +++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/modules/gpu/src/cuda/imgproc.cu b/modules/gpu/src/cuda/imgproc.cu index 5638ccd69b..8c53ae2d71 100644 --- a/modules/gpu/src/cuda/imgproc.cu +++ b/modules/gpu/src/cuda/imgproc.cu @@ -86,31 +86,39 @@ namespace imgproc const int x2 = x1 + 1; const int y2 = y1 + 1; - uchar3 src_reg = *(uchar3*)(src + y1 * src_step + 3 * x1); - out.x += src_reg.x * (x2 - xcoo) * (y2 - ycoo); - out.y += src_reg.y * (x2 - xcoo) * (y2 - ycoo); - out.z += src_reg.z * (x2 - xcoo) * (y2 - ycoo); + uchar src_reg = *(src + y1 * src_step + 3 * x1); + out.x += src_reg * (x2 - xcoo) * (y2 - ycoo); + src_reg = *(src + y1 * src_step + 3 * x1 + 1); + out.y += src_reg * (x2 - xcoo) * (y2 - ycoo); + src_reg = *(src + y1 * src_step + 3 * x1 + 2); + out.z += src_reg * (x2 - xcoo) * (y2 - ycoo); - src_reg = *(uchar3*)(src + y1 * src_step + 3 * x2); - - out.x += src_reg.x * (xcoo - x1) * (y2 - ycoo); - out.y += src_reg.y * (xcoo - x1) * (y2 - ycoo); - out.z += src_reg.z * (xcoo - x1) * (y2 - ycoo); + src_reg = *(src + y1 * src_step + 3 * x2); + out.x += src_reg * (xcoo - x1) * (y2 - ycoo); + src_reg = *(src + y1 * src_step + 3 * x2 + 1); + out.y += src_reg * (xcoo - x1) * (y2 - ycoo); + src_reg = *(src + y1 * src_step + 3 * x2 + 2); + out.z += src_reg * (xcoo - x1) * (y2 - ycoo); - src_reg = *(uchar3*)(src + y2 * src_step + 3 * x1); - - out.x += src_reg.x * (x2 - xcoo) * (ycoo - y1); - out.y += src_reg.y * (x2 - xcoo) * (ycoo - y1); - out.z += src_reg.z * (x2 - xcoo) * (ycoo - y1); + src_reg = *(src + y2 * src_step + 3 * x1); + out.x += src_reg * (x2 - xcoo) * (ycoo - y1); + src_reg = *(src + y2 * src_step + 3 * x1 + 1); + out.y += src_reg * (x2 - xcoo) * (ycoo - y1); + src_reg = *(src + y2 * src_step + 3 * x1 + 2); + out.z += src_reg * (x2 - xcoo) * (ycoo - y1); - src_reg = *(uchar3*)(src + y2 * src_step + 3 * x2); - - out.x += src_reg.x * (xcoo - x1) * (ycoo - y1); - out.y += src_reg.y * (xcoo - x1) * (ycoo - y1); - out.z += src_reg.z * (xcoo - x1) * (ycoo - y1); + src_reg = *(src + y2 * src_step + 3 * x2); + out.x += src_reg * (xcoo - x1) * (ycoo - y1); + src_reg = *(src + y2 * src_step + 3 * x2 + 1); + out.y += src_reg * (xcoo - x1) * (ycoo - y1); + src_reg = *(src + y2 * src_step + 3 * x2 + 2); + out.z += src_reg * (xcoo - x1) * (ycoo - y1); } - *(uchar3*)(dst + y * dst_step + 3 * x) = out; + /**(uchar3*)(dst + y * dst_step + 3 * x) = out;*/ + *(dst + y * dst_step + 3 * x) = out.x; + *(dst + y * dst_step + 3 * x + 1) = out.y; + *(dst + y * dst_step + 3 * x + 2) = out.z; } } }