'Filters this image using the given filter.  For a list of
available filters, see the :py:mod:`~PIL.ImageFilter` module.
:param filter: Filter kernel.
:returns: An :py:class:`~PIL.Image.Image` object.'

def filter(self, filter):

    self.load()
    if isinstance(filter, collections.Callable):
        filter = filter()
    if (not hasattr(filter, 'filter')):
        raise TypeError(('filter    argument    should    be    ImageFilter.Filter    ' + 'instance    or    class'))
    if (self.im.bands == 1):
        return self._new(filter.filter(self.im))
    ims = []
    for c in range(self.im.bands):
        ims.append(self._new(filter.filter(self.im.getband(c))))
    return merge(self.mode, ims)
