image padding

hello,
has someone got a an idea how to parallize image padding (like matlab padarray with replicate option) in C for CUDA on device, assuming you’re getting a pointer passed to an image, with improper dimensions for further processing. i need to write some algorithms for transform, filtering and motion estimation, not on images but on volumes, like CT produces. the main issue i am having right now is about correctly padding the data since all of the aforementioned algorithms require it…

would be nice if someone has an idea External Image

thanks

I think Nvidia NPP has some padding functions that can help you!

yes there is this group of methods “Copy Const Border” but they apply only a constant border whereas i need a replicate option (http://www.mathworks.com/help/toolbox/images/ref/padarray.html). either way its only operating on two-dimensional datas and i need to work on volumes.

Not sure exactly what it is you are trying to do but I wrote something for padding a 2d image into a array which was 4 x larger for the purposes of upsampling an FFT. I just had each thread for the larger array check if it should have a value from the original array in it or not. Not exactly sure what the replicate option is though.

EDIT: read your link and replicate shouldn’t be too much harder.

i want to pad the volume in such a way, that i can specify how many pixels(actually voxels since its a volume) to top,buttom,left,right,front and back are being added. replicate means the value of the voxel on the original border is continued to the border of the padded volume. simply creating a second volume with the desired dimensions would not be preferable, because all of it should take place on the GPU and the memory might be insufficient.

Oh right I understand you now. I’m not aware of how you can pad it by modifying the original array as I have no idea if it is even possible to dynamically change your array sizes. If you had the memory to hold your original and padded array on the GPU at once it shouldn’t be difficult at all to pad with different amounts of each side whilst replicating the border values. It maybe that this way is inefficient though?

I couldn’t find another way to do it myself because I wasnt actually padding from the outside edge of the array. I actually needed to pad spaces into the center of the array and push my data into the four corners.