Speed up Image.getchannel(), Image.merge(), Image.putalpha() and Image.split()#9675
Speed up Image.getchannel(), Image.merge(), Image.putalpha() and Image.split()#9675akx wants to merge 1 commit into
Image.getchannel(), Image.merge(), Image.putalpha() and Image.split()#9675Conversation
.merge()/.split() and friendsImage.getchannel(), Image.merge(), Image.putalpha() and Image.split()
| @@ -47,16 +47,19 @@ ImagingGetBand(Imaging imIn, int band) { | |||
| } | |||
|
|
|||
| /* Extract band from image */ | |||
There was a problem hiding this comment.
| /* Extract band from image */ | |
| // Extract band from image |
Maybe this is nicer than having a multiline comment next to a single line comment?
There was a problem hiding this comment.
Not sure it matters that much? I just didn't want to touch the original code or comment format here :)
| @@ -92,33 +95,37 @@ ImagingSplit(Imaging imIn, Imaging bands[4]) { | |||
| } | |||
|
|
|||
| /* Extract bands from image */ | |||
There was a problem hiding this comment.
| /* Extract bands from image */ | |
| // Extract bands from image |
| @@ -195,10 +202,13 @@ ImagingPutBand(Imaging imOut, Imaging imIn, int band) { | |||
| } | |||
|
|
|||
| /* Insert band into image */ | |||
There was a problem hiding this comment.
| /* Insert band into image */ | |
| // Insert band into image |
This comment was marked as outdated.
This comment was marked as outdated.
|
Updated now #9654 is merged. |
Merging this PR will improve performance by 85.18%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_merge[1024x1024-RGBA] |
10.1 ms | 5.4 ms | +87.77% |
| ⚡ | test_merge[1024x1024-RGB] |
8.4 ms | 4.5 ms | +86.05% |
| ⚡ | test_merge[1024x1024-LA] |
6.7 ms | 3.7 ms | +81.78% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing akx:bands-loops (23f5f76) with main (086fa4a)
Refs #9649 (same technique, different loops).
On my machine, this speeds up
.merge()for RGB images by about 3x according to the benchmark code from #9654.