MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / resize_linear_8u

Function resize_linear_8u

dnn/src/naive/resize/resize_cv.cpp:307–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307void resize_linear_8u(const Mat8u& src, Mat8u& dst) {
308 AlignedVector<int> tabsx(dst.rows());
309 AlignedVector<int> tabsy(dst.cols());
310 AlignedVector<int> tabrx(dst.rows());
311 AlignedVector<int> tabry(dst.cols());
312 build_tabs_linear_8u(src, dst, tabsx, tabsy, tabrx, tabry);
313 const size_t ch = src.channels();
314 const int ONE = 1 << SCALE;
315 // brute-force
316 for (size_t dx = 0; dx < dst.rows(); ++dx) {
317 const uchar* psrc0 = src.ptr(tabsx[dx] + 0);
318 const uchar* psrc1 = src.ptr(tabsx[dx] + 1);
319 uchar* pdst = dst.ptr(dx);
320 for (size_t dy = 0; dy < dst.cols(); ++dy) {
321 uchar* pcdst = pdst + dy * ch;
322 const uchar* pcsrc00 = psrc0 + (tabsy[dy] + 0) * ch;
323 const uchar* pcsrc01 = psrc0 + (tabsy[dy] + 1) * ch;
324 const uchar* pcsrc10 = psrc1 + (tabsy[dy] + 0) * ch;
325 const uchar* pcsrc11 = psrc1 + (tabsy[dy] + 1) * ch;
326 for (size_t c = 0; c < ch; ++c) {
327 int res = pcsrc11[c] * tabrx[dx] * tabry[dy] +
328 pcsrc10[c] * tabrx[dx] * (ONE - tabry[dy]) +
329 pcsrc01[c] * (ONE - tabrx[dx]) * tabry[dy] +
330 pcsrc00[c] * (ONE - tabrx[dx]) * (ONE - tabry[dy]);
331 pcdst[c] = static_cast<uchar>(
332 (res + (1 << (SCALE + SCALE - 1))) >> SCALE >> SCALE);
333 }
334 }
335 }
336}
337
338const int INTER_RESIZE_COEF_BITS = 11;
339const int INTER_RESIZE_COEF_SCALE = 1 << INTER_RESIZE_COEF_BITS;

Callers 1

resize_cv_execMethod · 0.70

Calls 5

build_tabs_linear_8uFunction · 0.70
rowsMethod · 0.45
colsMethod · 0.45
channelsMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected