guided filter: properly validate radius parameter before calling boxblur

This commit is contained in:
Alberto Griggio
2018-10-10 22:49:12 +02:00
parent 30d8a674aa
commit 02a15bc58d
2 changed files with 1 additions and 2 deletions

View File

@@ -35,8 +35,6 @@ namespace rtengine
template<class T, class A> void boxblur (T** src, A** dst, int radx, int rady, int W, int H)
{
//box blur image; box range = (radx,rady)
radx = min(radx, W-1);
rady = min(rady, H-1);
AlignedBuffer<float>* buffer = new AlignedBuffer<float> (W * H);
float* temp = buffer->data;

View File

@@ -110,6 +110,7 @@ void guidedFilter(const array2D<float> &guide, const array2D<float> &src, array2
const auto f_mean =
[](array2D<float> &d, array2D<float> &s, int rad) -> void
{
rad = min(rad, s.width() / 2, s.height() / 2);
boxblur<float, float>(s, d, rad, rad, s.width(), s.height());
};