Commit c08696f
committed
LibGfx: Make Bayer dithering more luminosity-conservative
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.1 parent 64f08ba commit c08696f
File tree
2 files changed
+50
-1
lines changed- Tests/LibGfx
- Userland/Libraries/LibGfx/ImageFormats
2 files changed
+50
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
315 | 319 | | |
316 | 320 | | |
317 | | - | |
| 321 | + | |
318 | 322 | | |
319 | 323 | | |
320 | 324 | | |
| |||
0 commit comments