diff --git a/_imaging.c b/_imaging.c index 1759d4c8d..17cfe2bfa 100644 --- a/_imaging.c +++ b/_imaging.c @@ -1791,7 +1791,6 @@ _unsharp_mask(ImagingObject* self, PyObject* args) if (!PyArg_ParseTuple(args, "fii", &radius, &percent, &threshold)) return NULL; - imIn = self->image; imOut = ImagingNew(imIn->mode, imIn->xsize, imIn->ysize); if (!imOut) @@ -1804,6 +1803,27 @@ _unsharp_mask(ImagingObject* self, PyObject* args) } #endif +static PyObject* +_box_blur(ImagingObject* self, PyObject* args) +{ + Imaging imIn; + Imaging imOut; + + int radius; + if (!PyArg_ParseTuple(args, "i", &radius)) + return NULL; + + imIn = self->image; + imOut = ImagingNew(imIn->mode, imIn->xsize, imIn->ysize); + if (!imOut) + return NULL; + + if (!ImagingBoxBlur(imIn, imOut, radius)) + return NULL; + + return PyImagingNew(imOut); +} + /* -------------------------------------------------------------------- */ static PyObject* @@ -3078,6 +3098,8 @@ static struct PyMethodDef methods[] = { {"unsharp_mask", (PyCFunction)_unsharp_mask, 1}, #endif + {"box_blur", (PyCFunction)_box_blur, 1}, + #ifdef WITH_EFFECTS /* Special effects */ {"effect_spread", (PyCFunction)_effect_spread, 1}, diff --git a/libImaging/BoxBlur.c b/libImaging/BoxBlur.c new file mode 100644 index 000000000..fe57ebf97 --- /dev/null +++ b/libImaging/BoxBlur.c @@ -0,0 +1,8 @@ +#include "Python.h" +#include "Imaging.h" + + +Imaging ImagingBoxBlur(Imaging im, Imaging imOut, int radius) +{ + return imOut; +} diff --git a/libImaging/Imaging.h b/libImaging/Imaging.h index d958387c9..e6f290fc3 100644 --- a/libImaging/Imaging.h +++ b/libImaging/Imaging.h @@ -308,6 +308,7 @@ extern Imaging ImagingTransform( int fill); extern Imaging ImagingUnsharpMask( Imaging im, Imaging imOut, float radius, int percent, int threshold); +extern Imaging ImagingBoxBlur(Imaging im, Imaging imOut, int radius); extern Imaging ImagingCopy2(Imaging imOut, Imaging imIn); extern Imaging ImagingConvert2(Imaging imOut, Imaging imIn); diff --git a/setup.py b/setup.py index 2d8cafa34..95d54df01 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ _LIB_IMAGING = ( "RankFilter", "RawDecode", "RawEncode", "Storage", "SunRleDecode", "TgaRleDecode", "Unpack", "UnpackYCC", "UnsharpMask", "XbmDecode", "XbmEncode", "ZipDecode", "ZipEncode", "TiffDecode", "Incremental", - "Jpeg2KDecode", "Jpeg2KEncode") + "Jpeg2KDecode", "Jpeg2KEncode", "BoxBlur") def _add_directory(path, dir, where=None):