

def __call__(self, *frames, **kwargs):
    channel = kwargs.get('channel', lib.DefaultChannels)
    c_channel = ffi.cast('ChannelType', channel)
    for f in frames:
        assert isinstance(f, ImageFrame)
    frame = frames[0]
    with magick_try() as exc:
        new_stack = lib.CloneImage(frame._frame, 0, 0, lib.MagickTrue, exc.ptr)
        exc.check((new_stack == ffi.NULL))
    out_view = lib.AcquireCacheView(new_stack)
    in_view = lib.AcquireCacheView(frame._frame)
    state = FilterState()
    for y in range(frame._frame.rows):
        with magick_try() as exc:
            q = lib.GetCacheViewAuthenticPixels(out_view, 0, y, frame._frame.columns, 1, exc.ptr)
            exc.check((q == ffi.NULL))
        for x in range(frame._frame.columns):
            state._color = BaseColor._from_pixel(q)
            ret = self.impl(state)
            rgb = ret.rgb()
            lib.sanpera_pixel_from_doubles_channel(q, rgb._array, c_channel)
            q += 1
        with magick_try() as exc:
            lib.SyncCacheViewAuthenticPixels(in_view, exc.ptr)
    return Image(new_stack)

dataset/ETHPy150Open eevee/sanpera/sanpera/filters.py python_image_filter.__call__/original