ppwwyyxx / OpenPano

Automatic Panorama Stitching From Scratch
MIT License
1.86k stars 553 forks source link

Confirming the calculation of Gaussian Blur #52

Closed ghost closed 6 years ago

ghost commented 6 years ago

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]?

// by rows  
cur_line[center + j] = v0;
cur_line[w + j] = v0;

Padding by columns

                // 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;
}
ppwwyyxx commented 6 years ago

You're right! This looks like a bug!