FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fast filters by homm · Pull Request #2679 · python-pillow/Pillow · GitHub

Fast filters - #2679

Merged
wiredfool merged 21 commits into
python-pillow:masterfrom
uploadcare:fast-filters
Sep 10, 2017
Merged

Fast filters#2679
wiredfool merged 21 commits into
python-pillow:masterfrom
uploadcare:fast-filters

Conversation

homm commented Aug 12, 2017
edited
Loading

Copy link
Copy Markdown
Member
               Ubuntu 14.04    i2f or 16.04       Optimized
Smooth        12.47 Mpx/s     28.81 Mpx/s       44.71 Mpx/s
Sharpen       12.34 Mpx/s     29.94 Mpx/s       44.74 Mpx/s
Smooth More    4.41 Mpx/s     12.49 Mpx/s       17.61 Mpx/s

Comment thread PIL/Image.py Outdated
"instance or class")

if self.im.bands == 1:
multiband = getattr(filter, 'is_multiband', False)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

All filters used to work only with single-channel images. As this is public API and there are can be custom filters in a wild, we can't just send multi-channel images to all filters. So is_multiband flag indicates that the filter is ready for multi-channel images.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@wiredfool As of naming things is one of the hard problems in programming, I need your help there )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think that's a reasonable name, at least, I haven't thought of anything better.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The another option is subclass MultibandFilter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That's probably cleaner, especially with an eye towards the typing PR.

Comment thread _imaging.c
}

for (i = 0; i < kernelsize; ++i) {
kerneldata[i] /= divisor;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Precompute by dividing coefficients to divisor rather than each result pixel.

homm added this to the 4.3.0 milestone Aug 12, 2017

homm commented Aug 13, 2017

Copy link
Copy Markdown
Member Author

Oh my god! I clash with the same bug in Intel x64 CPUs with int to float conversion, as I did when was working on resampling for Pillow 2.7.

In essence: GCC version < 4.9 (at least Ubuntu 14.04, Debian 7 Wheezy, Red Hat Linux 7) generates code which runs about 2.5 times slower than GCC >= 4.9. This can be fixed using ugly hack with assembler. We decided to include this hack in Pillow 2.7 (released Jan 1, 2015). After rewriting the resampling using fixed point arithmetics, this hack become obsolete and was removed in Pillow 3.3 (Jul 1, 2016). Unlike for resampling, I don't see a way to implement kernel filters on FPA. So, I suggest to include this hack again.

homm commented Aug 13, 2017
edited
Loading

Copy link
Copy Markdown
Member Author

I've just tried SSE4 for multiband images, with no specific optimizations some optimizations.

                Simple SSE4     Optimized SSE4    OpenCV
Smooth         137.25 Mpx/s    192.01 Mpx/s      163.68 Mpx/s
Sharpen        133.55 Mpx/s    171.32 Mpx/s      163.81 Mpx/s
Smooth More     45.71 Mpx/s     69.34 Mpx/s       64.01 Mpx/s

homm removed the Needs Tests label Aug 15, 2017

homm commented Sep 10, 2017

Copy link
Copy Markdown
Member Author

@wiredfool implemented through MultibandFilter

wiredfool merged commit 3b5c2c3 into python-pillow:master Sep 10, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL