Add primary color dithering to ImageOps#9339
Open
Marcelo-MConti wants to merge 11 commits intopython-pillow:mainfrom
Open
Add primary color dithering to ImageOps#9339Marcelo-MConti wants to merge 11 commits intopython-pillow:mainfrom
Marcelo-MConti wants to merge 11 commits intopython-pillow:mainfrom
Conversation
for more information, see https://pre-commit.ci
radarhere
reviewed
Dec 12, 2025
radarhere
reviewed
Dec 12, 2025
radarhere
reviewed
Dec 12, 2025
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Member
|
I've created Marcelo-MConti#1 to fix the lint failures. |
thanks for fix the lint failures
Member
|
I've created Marcelo-MConti#2 with an idea - process the image by band, instead of all bands at once. I find it is a bit faster, and neater. |
Author
|
Thanks so much for your help! |
radarhere
reviewed
Dec 22, 2025
| return 255 if quadrant in (0, 3) else 0 | ||
| if value > 32: | ||
| return 255 if quadrant == 1 else 0 | ||
| return 0 |
Member
There was a problem hiding this comment.
Did you want to explain a bit where this logic comes from? Why value > 233, why quadrant in (0, 3), etc.?
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.
What does this PR do?
This PR adds a new image operation to
PIL.ImageOpsthat applies aprimary-color dithering filter (RGB only).
The filter:
Why is this useful?
Primary-color dithering can be useful for:
What is included?
ImageOps.dither_primaryNotes
Before Filter
After Filter