Speedup for guided filter
This commit is contained in:
@@ -207,9 +207,6 @@ void guidedFilter(const array2D<float> &guide, const array2D<float> &src, array2
|
|||||||
apply(SUBMUL, b, a, meanI, meanp);
|
apply(SUBMUL, b, a, meanI, meanp);
|
||||||
DEBUG_DUMP(b);
|
DEBUG_DUMP(b);
|
||||||
|
|
||||||
meanI.free(); // frees w * h * 4 byte
|
|
||||||
meanp.free(); // frees w * h * 4 byte
|
|
||||||
|
|
||||||
array2D<float> &meana = a;
|
array2D<float> &meana = a;
|
||||||
f_mean(meana, a, r1);
|
f_mean(meana, a, r1);
|
||||||
DEBUG_DUMP(meana);
|
DEBUG_DUMP(meana);
|
||||||
@@ -218,18 +215,25 @@ void guidedFilter(const array2D<float> &guide, const array2D<float> &src, array2
|
|||||||
f_mean(meanb, b, r1);
|
f_mean(meanb, b, r1);
|
||||||
DEBUG_DUMP(meanb);
|
DEBUG_DUMP(meanb);
|
||||||
|
|
||||||
blur_buf.resize(0); // frees w * h * 4 byte
|
const int Ws = meana.width();
|
||||||
|
const int Hs = meana.height();
|
||||||
|
const int Wd = q.width();
|
||||||
|
const int Hd = q.height();
|
||||||
|
|
||||||
array2D<float> meanA(W, H);
|
float col_scale = float (Ws) / float (Wd);
|
||||||
f_upsample(meanA, meana);
|
float row_scale = float (Hs) / float (Hd);
|
||||||
DEBUG_DUMP(meanA);
|
|
||||||
|
|
||||||
array2D<float> &meanB = q;
|
#ifdef _OPENMP
|
||||||
f_upsample(meanB, meanb);
|
#pragma omp parallel for if (multithread)
|
||||||
DEBUG_DUMP(meanB);
|
#endif
|
||||||
|
|
||||||
apply(ADDMUL, q, meanA, I, meanB);
|
for (int y = 0; y < Hd; ++y) {
|
||||||
DEBUG_DUMP(q);
|
float ymrs = y * row_scale;
|
||||||
|
|
||||||
|
for (int x = 0; x < Wd; ++x) {
|
||||||
|
q[y][x] = getBilinearValue(meana, x * col_scale, ymrs) * I[y][x] + getBilinearValue(meanb, x * col_scale, ymrs);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace rtengine
|
} // namespace rtengine
|
||||||
|
Reference in New Issue
Block a user