diff --git a/rtengine/boxblur.h b/rtengine/boxblur.h index f38c8f6e4..805575b77 100644 --- a/rtengine/boxblur.h +++ b/rtengine/boxblur.h @@ -35,8 +35,6 @@ namespace rtengine template 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* buffer = new AlignedBuffer (W * H); float* temp = buffer->data; diff --git a/rtengine/guidedfilter.cc b/rtengine/guidedfilter.cc index 4f4c5a247..3000e1d5d 100644 --- a/rtengine/guidedfilter.cc +++ b/rtengine/guidedfilter.cc @@ -110,6 +110,7 @@ void guidedFilter(const array2D &guide, const array2D &src, array2 const auto f_mean = [](array2D &d, array2D &s, int rad) -> void { + rad = min(rad, s.width() / 2, s.height() / 2); boxblur(s, d, rad, rad, s.width(), s.height()); };