Skip to content

Commit d2eefef

Browse files
committed
methodology, why not contributed
1 parent 2e55786 commit d2eefef

File tree

1 file changed

+52
-27
lines changed

1 file changed

+52
-27
lines changed

README.md

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,32 @@ the result will be 61.7 Mpx/s.
5252
- Pillow 3.2.0
5353
- Pillow-SIMD 3.2.0.post1
5454

55-
Source | Operation | Filter | IM | Pillow | SIMD SSE4 | SIMD AVX2
56-
----------|---------------------|---------|------|--------|-----------|-----------
57-
7712x4352 | Resize to 16x16 | Bilinear| 27.0 | 217 | 456 | 545
58-
| | Bicubic | 10.9 | 115 | 240 | 278
59-
| | Lanczos | 6.6 | 76.1 | 162 | 194
60-
| Resize to 320x180 | Bilinear| 32.0 | 166 | 354 | 410
61-
| | Bicubic | 16.5 | 92.3 | 198 | 204
62-
| | Lanczos | 11.0 | 63.2 | 133 | 147
63-
| Resize to 2048x1155 | Bilinear| 20.7 | 87.6 | 202 | 217
64-
| | Bicubic | 12.2 | 65.7 | 126 | 130
65-
| | Lanczos | 8.7 | 41.3 | 88.2 | 95.6
66-
| Blur | 1px | 8.1 | 17.1 | 37.8
67-
| | 10px | 2.6 | 17.4 | 39.0
68-
| | 100px | 0.3 | 17.2 | 39.0
69-
1920x1280 | Resize to 16x16 | Bilinear| 41.6 | 196 | 422 | 489
70-
| | Bicubic | 18.9 | 102 | 225 | 263
71-
| | Lanczos | 13.7 | 68.6 | 118 | 167
72-
| Resize to 320x180 | Bilinear| 27.6 | 111 | 196 | 197
73-
| | Bicubic | 14.5 | 66.3 | 154 | 162
74-
| | Lanczos | 9.8 | 44.3 | 102 | 107
75-
| Resize to 2048x1155 | Bilinear| 9.1 | 20.7 | 71.3 | 72.6
76-
| | Bicubic | 6.3 | 16.9 | 49.3 | 54.3
77-
| | Lanczos | 4.7 | 14.6 | 36.8 | 40.6
78-
| Blur | 1px | 8.7 | 16.2 | 35.7
79-
| | 10px | 2.8 | 16.7 | 35.4
80-
| | 100px | 0.4 | 16.4 | 36.2
55+
Source | Operation | Filter | IM | Pillow | SIMD SSE4 | SIMD AVX2
56+
----------|-------------------------|---------|------|--------|-----------|-----------
57+
7712x4352 | **Resize to 16x16** | Bilinear| 27.0 | 217 | 456 | 545
58+
| | Bicubic | 10.9 | 115 | 240 | 278
59+
| | Lanczos | 6.6 | 76.1 | 162 | 194
60+
| **Resize to 320x180** | Bilinear| 32.0 | 166 | 354 | 410
61+
| | Bicubic | 16.5 | 92.3 | 198 | 204
62+
| | Lanczos | 11.0 | 63.2 | 133 | 147
63+
| **Resize to 2048x1155** | Bilinear| 20.7 | 87.6 | 202 | 217
64+
| | Bicubic | 12.2 | 65.7 | 126 | 130
65+
| | Lanczos | 8.7 | 41.3 | 88.2 | 95.6
66+
| **Blur** | 1px | 8.1 | 17.1 | 37.8
67+
| | 10px | 2.6 | 17.4 | 39.0
68+
| | 100px | 0.3 | 17.2 | 39.0
69+
1920x1280 | **Resize to 16x16** | Bilinear| 41.6 | 196 | 422 | 489
70+
| | Bicubic | 18.9 | 102 | 225 | 263
71+
| | Lanczos | 13.7 | 68.6 | 118 | 167
72+
| **Resize to 320x180** | Bilinear| 27.6 | 111 | 196 | 197
73+
| | Bicubic | 14.5 | 66.3 | 154 | 162
74+
| | Lanczos | 9.8 | 44.3 | 102 | 107
75+
| **Resize to 2048x1155** | Bilinear| 9.1 | 20.7 | 71.3 | 72.6
76+
| | Bicubic | 6.3 | 16.9 | 49.3 | 54.3
77+
| | Lanczos | 4.7 | 14.6 | 36.8 | 40.6
78+
| **Blur** | 1px | 8.7 | 16.2 | 35.7
79+
| | 10px | 2.8 | 16.7 | 35.4
80+
| | 100px | 0.4 | 16.4 | 36.2
8181

8282

8383
### Some conclusion
@@ -92,7 +92,20 @@ All tests done on Ubuntu 14.04 64-bit runing on
9292
Intel Core i5 4258U with AVX2 CPU on single thread.
9393

9494
ImageMagick performance measured with command-line tool `convert` with
95-
`-verbose` and `-bench` arguments
95+
`-verbose` and `-bench` arguments. I'm using command line because
96+
I needed to test latest version and this is to easist way to do that.
97+
All operations are producing exactly the same result.
98+
Resizing filters compliance:
99+
100+
- PIL.Image.BILINEAR == Triangle
101+
- PIL.Image.BICUBIC == Catrom
102+
- PIL.Image.LANCZOS == Lanczos
103+
104+
In ImageMagick the radius of gaussian blur called sigma and second parameter
105+
is called radius. In fact there should not be additional parameters for
106+
*gaussian blur*, because if the radius is too small, this is *not*
107+
gaussian blur anymore. And if the radius is big, this does not give any
108+
advantages, but makes operation slower. For test I set radius to sigma × 2.5.
96109

97110
Following script were used for testing:
98111
https://gist.github.com/homm/f9b8d8a84a57a7e51f9c2a5828e40e63
@@ -109,6 +122,18 @@ benchmakrs. And result is
109122

110123
## Why not to contribute SIMD to the original Pillow
111124

125+
Well, this is not so simple. First of all, Pillow support large number
126+
of architectures, not only x86. But even for x86 platforms Pillow orfen
127+
distributed via precompiled binaries. To integrate SIMD in precompiled binaries
128+
we need to do runtime checks of CPU capabilites.
129+
To compile code with runtime checks we need to pass `-mavx2` option
130+
to compiller. But this automaticaly activates all `if (__AVX2__)` and below
131+
conditions. And SIMD instructions under such conditions are exist
132+
even in standard C library and they do not have any runtime checks.
133+
Currently I don't know a way how to tell to compiller to allow SIMD
134+
instrustions in the code but *do not allow* using such instructions without
135+
runtime checks.
136+
112137

113138
## Installation
114139

0 commit comments

Comments
 (0)