Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #3678

https://pillow.readthedocs.io/en/stable/reference/ImageFilter.html#PIL.ImageFilter.Kernel

kernel – A sequence containing kernel weights.

The issue notes that this doesn't specify the order. As #3134 notes, Pillow does not use convolution order or correlation order.

https://towardsdatascience.com/convolution-vs-correlation-af868b6b4fb5 has figures 5d and 6g of this,

noting that

In Convolution operation, the kernel is first flipped by an angle of 180 degrees and is then applied to the image.

So our order, as noted by #3134, is

# result:
#[[0 0 0 0 0 0 0]
# [0 0 0 0 0 0 0]
# [0 0 3 2 1 0 0]
# [0 0 6 5 4 0 0]
# [0 0 9 8 7 0 0]
# [0 0 0 0 0 0 0]
# [0 0 0 0 0 0 0]]

which would be flipping the kernel vertically before applying it. I've added that note to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImageFilter.Kernel uses kernel weights in the wrong order?

2 participants