Skip to content

Use filters instead of a Python loop for sobel in neon() - #10516

Open
patrick-immometrica wants to merge 1 commit into
python-pillow:mainfrom
patrick-immometrica:faster-neon
Open

patrick-immometrica wants to merge 1 commit into
python-pillow:mainfrom
patrick-immometrica:faster-neon

Conversation

@patrick-immometrica

Copy link
Copy Markdown

Changes proposed in this pull request:

  • _sobel(), used by the new neon(), calls getpixel() nine times for every pixel. Since ImageFilter.Kernel clips to 0-255, abs(gx) is the kernel result plus the negated kernel result, so four 3x3 filters and ImageChops.add() give the same output.
  • neon() on a 1024x768 image goes from 1.89 sec to 6.61 msec.
python3 -m timeit -s "from PIL import Image, ImageOps; im = Image.open('Tests/images/hopper.png').resize((1024, 768))" "ImageOps.neon(im)"
  • Added a test with known values. It passes both before and after.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant