PDA

View Full Version : Convolution with Wrapped Edges



nelsong
11-13-2009, 11:14 PM
Hi everyone,

I'm trying to implement a simple iterated convolution kernel with edge wrapping. I have a few questions about how to do this most effectively.

What is the best way to implement edge wrapping in a kernel? Should I use modulo? Should I limit my buffers to widths/heights that are powers of two and use a bitwise and? Or should I avoid this altogether and use a larger buffer and copy the left edge to the right side and vice versa? If so, what's the best way to do this?

PaulS
11-14-2009, 07:32 AM
How about using a sampler variable that has CLK_ADDRESS_REPEAT set?

dbs2
11-15-2009, 03:33 AM
Paul is right if your input is an image. Just set the sampler to wrap. If you are using buffers and/or blocking into local memory you'll have to handle it yourself. In the case of using local memory you can just load the extra data for the edges. In general you'll want to have separate code-paths for the edge case/body case so you don't pay the conditional/modulo overhead on every calculation.)

wrx
04-20-2011, 06:42 AM
Hi,

I'm in this situation. I work with buffers of 3D image (~maybe~ will working with image2D, 3D later) and I want to know if
- using "gentype fmod (gentype x, gentype y)" will be fast enough? What"s the cost?
- using array(local, or global) with border value will be better than fmod ?

Exemple for border value with image[5][8] :
arrayX[8]={0,5,10,15,20,25,30,35}
arrayY[5]={0, 8, 16,24,32}

What is your knowledge/experience ?
Thank you!