Skip to content

Conversation

@LucasChollet
Copy link
Member

@LucasChollet LucasChollet commented Nov 27, 2025

On average, this patch reduces the error in luminosity between an input image and its dithered equivalent. This is done by correcting an off-by-one error in the threshold computation and also by making sure the range of mapped gray values to matrix pattern is of equal size for all ranges. This means that all values between 0 and 255 / (N * N + 1) (51 for
Bayer2x2) will result in a black pixel while only a value of 0 would previously do it.

The test works by first generating gray bitmap, then applying Bayer dithering on them and finally compare the luminosity of the two.


For a Bayer2x2:

After fixing off-by-one:

Gray value range Pattern #
0 0
1 - 64 1
65 - 127 2
128 - 190 3
190 - 255 4

After the full patch:

Gray value range Pattern #
0 - 51 0
52 - 101 1
102 - 152 2
153-203 3
204-255 4

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Nov 27, 2025
@Hendiadyoin1
Copy link
Contributor

Huh this seems to share a fix with #26432
but that one didn't have the +128 in there

@LucasChollet
Copy link
Member Author

Yeah, I'm writing a comment to explain it and I wanted to open that first to be able to reference it. But now I'm wondering if it's actually the best approach.

On average, this patch reduces the error in luminosity between an input
image and its dithered equivalent. This is done by correcting an off-by-
one error in the threshold computation and also by making sure the range
of mapped gray values to matrix pattern is of equal size for all ranges.
This means that all values between 0 and 255 / (N * N + 1) (51 for
Bayer2x2) will result in a black pixel while only a value of 0 would
previously do it.

The test works by first generating gray bitmap, then applying Bayer
dithering on them and finally compare the luminosity of the two.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 pr-needs-review PR needs review from a maintainer or community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants