Speed up Image.getchannel(), Image.merge(), Image.putalpha() and Image.split()#9675
Open
akx wants to merge 1 commit into
Open
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()#9675akx wants to merge 1 commit into
Conversation
.merge()/.split() and friendsImage.getchannel(), Image.merge(), Image.putalpha() and Image.split()
radarhere
reviewed
Jun 16, 2026
| @@ -47,16 +47,19 @@ ImagingGetBand(Imaging imIn, int band) { | |||
| } | |||
|
|
|||
| /* Extract band from image */ | |||
Member
There was a problem hiding this comment.
Suggested change
| /* Extract band from image */ | |
| // Extract band from image |
Maybe this is nicer than having a multiline comment next to a single line comment?
Contributor
Author
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 :)
radarhere
reviewed
Jun 16, 2026
| @@ -92,33 +95,37 @@ ImagingSplit(Imaging imIn, Imaging bands[4]) { | |||
| } | |||
|
|
|||
| /* Extract bands from image */ | |||
Member
There was a problem hiding this comment.
Suggested change
| /* Extract bands from image */ | |
| // Extract bands from image |
radarhere
reviewed
Jun 16, 2026
| @@ -195,10 +202,13 @@ ImagingPutBand(Imaging imOut, Imaging imIn, int band) { | |||
| } | |||
|
|
|||
| /* Insert band into image */ | |||
Member
There was a problem hiding this comment.
Suggested change
| /* Insert band into image */ | |
| // Insert band into image |
radarhere
reviewed
Jun 16, 2026
| UINT8 *in = imIn->image8[y]; | ||
| UINT8 *out = (UINT8 *)imOut->image[y] + band; | ||
| for (x = 0; x < imIn->xsize; x++) { | ||
| // restrict safe: imIn and imOut are distinct images (sizes checked above). |
Member
There was a problem hiding this comment.
I don't understand what 'sizes checked above' has to do with this.
radarhere
approved these changes
Jun 16, 2026
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.