guided filter: proper bounding of the radius before calling boxblur
This commit is contained in:
@@ -35,6 +35,8 @@ namespace rtengine
|
|||||||
template<class T, class A> void boxblur (T** src, A** dst, int radx, int rady, int W, int H)
|
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)
|
//box blur image; box range = (radx,rady)
|
||||||
|
assert(2*radx+1 < W);
|
||||||
|
assert(2*rady+1 < H);
|
||||||
|
|
||||||
AlignedBuffer<float>* buffer = new AlignedBuffer<float> (W * H);
|
AlignedBuffer<float>* buffer = new AlignedBuffer<float> (W * H);
|
||||||
float* temp = buffer->data;
|
float* temp = buffer->data;
|
||||||
|
@@ -110,7 +110,7 @@ void guidedFilter(const array2D<float> &guide, const array2D<float> &src, array2
|
|||||||
const auto f_mean =
|
const auto f_mean =
|
||||||
[](array2D<float> &d, array2D<float> &s, int rad) -> void
|
[](array2D<float> &d, array2D<float> &s, int rad) -> void
|
||||||
{
|
{
|
||||||
rad = min(rad, s.width() / 2, s.height() / 2);
|
rad = LIM(rad, 0, (min(s.width(), s.height()) - 1) / 2 - 1);
|
||||||
boxblur<float, float>(s, d, rad, rad, s.width(), s.height());
|
boxblur<float, float>(s, d, rad, rad, s.width(), s.height());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user