123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- __kernel void padding_2d_init_const(
- __global float * out_img,
- const unsigned int nxs,
- const float pval)
- {
- const int idx = get_global_id(0);
- const int idy = get_global_id(1);
- const int lidx = idy * nxs + idx;
- out_img[lidx] = pval;
- }
- __kernel void padding_2d_copy_in(
- __global float * inp_img,
- __global float * out_img,
- const unsigned int sxs,
- const unsigned int lxs,
- const unsigned int xl,
- const unsigned int yt)
- {
- const int idx = get_global_id(0);
- const int idy = get_global_id(1);
- const int lidx = (idy + yt) * lxs + (idx + xl);
- const int sidx = idy * sxs + idx;
- out_img[lidx] = inp_img[sidx];
- }
- __kernel void padding_2d_brep(
- __global float * inp_img,
- __global float * out_img,
- const unsigned int sxs,
- const unsigned int syz,
- const unsigned int lxs,
- const unsigned int xl,
- const unsigned int yt)
- {
- const int idx = get_global_id(0);
- const int idy = get_global_id(1);
- const int lidx = idy * lxs + idx;
- const int sidx = (idy - yt) * sxs + (idx - xl);
- if( idy < yt)
- {
- if(idx < xl)
- out_img[lidx] = inp_img[0]; // top left
- else if(idx >= (xl+sxs))
- out_img[lidx] = inp_img[sxs-1]; // top right
- else
- out_img[lidx] = inp_img[idx-xl]; // top center
- return;
- }
- if( idy >= (yt + syz))
- {
- if(idx < xl)
- out_img[lidx] = inp_img[(syz-1)*sxs]; // bottom left
- else if(idx >= (xl+sxs))
- out_img[lidx] = inp_img[syz*sxs-1]; // bottom right
- else
- out_img[lidx] = inp_img[(syz-1)*sxs +(idx-xl)]; // bottom center
- return;
- }
- if(idx < xl)
- {
- out_img[lidx] = inp_img[(idy-yt)*sxs]; // center left
- return;
- }
-
- if(idx >= (xl+sxs))
- {
- out_img[lidx] = inp_img[(idy-yt)*sxs + (sxs -1)]; // center right
- return;
- }
- out_img[lidx] = inp_img[sidx]; // center center
- }
|