From 103bbaf09c0a118288b62900e45cb52cb1906984 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Fri, 3 Dec 2010 13:28:49 +0000 Subject: [PATCH] updated BrdReflect101 in gpu module --- modules/gpu/src/cuda/border_interpolate.hpp | 68 ++++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/modules/gpu/src/cuda/border_interpolate.hpp b/modules/gpu/src/cuda/border_interpolate.hpp index 26b19cb10..7bfcf82aa 100644 --- a/modules/gpu/src/cuda/border_interpolate.hpp +++ b/modules/gpu/src/cuda/border_interpolate.hpp @@ -53,12 +53,12 @@ namespace cv { namespace gpu { __device__ int idx_high(int i) const { - return last - abs(i - last); + return last - abs(last - i); } __device__ int idx(int i) const { - return i <= last ? idx_low(i) : idx_high(i); + return abs(idx_high(i)); } bool is_range_safe(int mini, int maxi) const @@ -105,4 +105,68 @@ namespace cv { namespace gpu { int step; }; + + struct BrdReplicate + { + BrdReplicate(int len) : last(len - 1) {} + + __device__ int idx_low(int i) const + { + return max(i, 0); + } + + __device__ int idx_high(int i) const + { + return min(i, last); + } + + __device__ int idx(int i) const + { + return min(max(i, last), 0); + } + + bool is_range_safe(int mini, int maxi) const + { + return true; + } + + int last; + }; + + + template + struct BrdRowReplicate: BrdReplicate + { + BrdRowReplicate(int len) : BrdReplicate(len) {} + + __device__ float at_low(int i, const T* data) const + { + return data[idx_low(i)]; + } + + __device__ float at_high(int i, const T* data) const + { + return data[idx_high(i)]; + } + }; + + + template + struct BrdColReplicate: BrdReplicate + { + BrdColReplicate(int len, int step) : BrdReplicate(len), step(step) {} + + __device__ float at_low(int i, const T* data) const + { + return data[idx_low(i) * step]; + } + + __device__ float at_high(int i, const T* data) const + { + return data[idx_high(i) * step]; + } + + int step; + }; + }} \ No newline at end of file