Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageFilter.Kernel uses kernel weights in the wrong order? #3678

Open
carlosefr opened this issue Feb 27, 2019 · 3 comments
Open

ImageFilter.Kernel uses kernel weights in the wrong order? #3678

carlosefr opened this issue Feb 27, 2019 · 3 comments
Labels
Bug
Projects

Comments

@carlosefr
Copy link

@carlosefr carlosefr commented Feb 27, 2019

What did you do?

I'm using the ImageFilter.Kernel filter with a 3x3 kernel that should shift the image down by one pixel, but instead it is shifting the image one pixel up.

I'm assuming the order of weights in the kernel is left-right, top-bottom because, AFAIK, the documentation doesn't specify the order and I assume it uses the same ordering/coordinates as the image itself.

So, this is either a bug in the code, or a bug in the documentation.

What did you expect to happen?

The image should be shifted one pixel down.

What actually happened?

The image is shifted one pixel up.

What are your OS, Python and Pillow versions?

  • OS: CentOS Linux 7.6
  • Python: 3.6.7
  • Pillow: 5.4.1
from PIL import Image, ImageFilter

shift_down = (
    0, 1, 0,
    0, 0, 0,
    0, 0, 0,
)

original_image = Image.open("images/example.png", mode="r")
filtered_image = original_image.filter(ImageFilter.Kernel((3, 3), shift_down))
filtered_image.save("filtered.png", format="PNG")
@carlosefr
Copy link
Author

@carlosefr carlosefr commented Feb 27, 2019

Additional note, this kernel shifts the image left by one pixel as expected:

shift_left = (
    0, 0, 0,
    0, 0, 1,
    0, 0, 0,
)
@hugovk
Copy link
Member

@hugovk hugovk commented Feb 27, 2019

Possibly related to #3134?

@aclark4life aclark4life added the Bug label May 11, 2019
@aclark4life aclark4life added this to Backlog in Pillow May 11, 2019
@aclark4life aclark4life moved this from Backlog to In progress in Pillow May 11, 2019
@homm
Copy link
Member

@homm homm commented Dec 31, 2019

This can't ever be fixed due to backward compatibility. Think about this as a call convention. The only we can do is update documentation. Pull requests are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Pillow
  
In progress
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.