diff --git a/PIL/ImageMorph.py b/PIL/ImageMorph.py index 7996a48aa..ca9b3bb80 100644 --- a/PIL/ImageMorph.py +++ b/PIL/ImageMorph.py @@ -195,7 +195,7 @@ class MorphOp: raise Exception('No operator loaded') outimage = Image.new(image.mode, image.size, None) - count = _imagingmorph.apply(self.lut, image.im.id, outimage.im.id) + count = _imagingmorph.apply(bytes(self.lut), image.im.id, outimage.im.id) return count, outimage def match(self, image): @@ -205,7 +205,7 @@ class MorphOp: if self.lut is None: raise Exception('No operator loaded') - return _imagingmorph.match(self.lut, image.im.id) + return _imagingmorph.match(bytes(self.lut), image.im.id) def get_on_pixels(self, image): """Get a list of all turned on pixels in a binary image diff --git a/_imagingmorph.c b/_imagingmorph.c index 68a1db35b..7e7fdd879 100644 --- a/_imagingmorph.c +++ b/_imagingmorph.c @@ -45,19 +45,19 @@ apply(PyObject *self, PyObject* args) return NULL; } - if (!PyByteArray_Check(py_lut)) { - PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a byte array"); + if (!PyBytes_Check(py_lut)) { + PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a bytes object"); return NULL; } - lut_len = PyByteArray_Size(py_lut); + lut_len = PyBytes_Size(py_lut); if (lut_len < LUT_SIZE) { PyErr_SetString(PyExc_RuntimeError, "The morphology LUT has the wrong size"); return NULL; } - lut = PyByteArray_AsString(py_lut); + lut = PyBytes_AsString(py_lut); imgin = (Imaging) i0; imgout = (Imaging) i1; @@ -152,19 +152,19 @@ match(PyObject *self, PyObject* args) return NULL; } - if (!PyByteArray_Check(py_lut)) { - PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a byte array"); + if (!PyBytes_Check(py_lut)) { + PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a bytes object"); return NULL; } - lut_len = PyByteArray_Size(py_lut); + lut_len = PyBytes_Size(py_lut); if (lut_len < LUT_SIZE) { PyErr_SetString(PyExc_RuntimeError, "The morphology LUT has the wrong size"); return NULL; } - lut = PyByteArray_AsString(py_lut); + lut = PyBytes_AsString(py_lut); imgin = (Imaging) i0; if (imgin->type != IMAGING_TYPE_UINT8 &&