// pad the border with border value
T v0 = cur_line[0];
for (int i = 1; i <= center; i ++)
cur_line[-i] = v0;
v0 = cur_line[h - 1];
for (int i = 0; i < center; i ++)
cur_line[h + i] = v0;
Padding by rows
// apply to rows
REP(i, h) {
T *dest = ret.ptr(i);
memcpy(cur_line, dest, sizeof(T) * w);
{ // pad the border
T v0 = cur_line[0];
for (int j = 1; j <= center; j ++)
cur_line[-j] = v0;
v0 = cur_line[w - 1];
for (int j = 0; j < center; j ++)
cur_line[center + j] = v0;
}
When checking the algorithm of Gaussian Blur, I am confused by the padding border by rows in the implementation.
When padding by rows, why the index is
[center+j]
, instead of[w + j]
?Padding by columns
Padding by rows