opencl - Need function that mirrors image coordinates outside of boundaries -
i performing nxn image convolution on image of dimensions w , h, n much smaller w or h. given coordinate alpha, calculate new coordinate safe_alpha guaranteed lie in bounds. coordinates outside of boundary should mirrored.
i.e., if
alpha = (w-1) +2; then
safe_alpha = (w-1) -2; this running on gpu, prefer avoid conditionals in calculation.
mirroring on outer boundary simple:
safe_alpha = -| (w-1) - alpha| + alpha; but need mirror on both.
edit:
here seems work, not sure if fastest:
safe_alpha = |alpha| + (alpha/(w-1)) * (alpha - (w-1));
i don't know opencl details, can avoid border info mirroring using appropriate convolution window @ edges: convolution window values double image border values. need n/2 array of convolution windows (once derived original n*n window) every 4 border , bit more corners, no conditionals , no devisions @ all.
image-processing opencl
No comments:
Post a Comment