Commit Graph

8613 Commits

Author SHA1 Message Date
Kartik K. Agaram d771fb6bab more powerful load-sectors 2021-07-16 08:58:15 -07:00
Kartik K. Agaram 96c217ab1c . 2021-07-16 08:48:40 -07:00
Kartik K. Agaram 7247b9cfb9 . 2021-07-16 08:41:28 -07:00
Kartik K. Agaram 78357b8852 . 2021-07-16 08:38:43 -07:00
Kartik K. Agaram 44d26b77c4 . 2021-07-16 08:28:56 -07:00
Kartik K. Agaram ac45f09715 . 2021-07-16 06:13:51 -07:00
Kartik K. Agaram cd9a3fe3ad . 2021-07-16 06:12:51 -07:00
Kartik K. Agaram 055d8d7869 . 2021-07-16 06:09:30 -07:00
Kartik K. Agaram 62c64772e7 . 2021-07-15 19:59:00 -07:00
Kartik K. Agaram 8679001f5c . 2021-07-14 01:54:25 -07:00
Kartik K. Agaram f1cdea5dab color dithering seems to be working 2021-07-14 01:46:53 -07:00
Kartik K. Agaram d03dd5dff7 . 2021-07-14 01:31:14 -07:00
Kartik K. Agaram e0d86d6537 . 2021-07-14 01:25:18 -07:00
Kartik K. Agaram 648d9432b6 clarify a corner case in 2's complement integers
https://merveilles.town/@akkartik/106577885001702701
2021-07-14 01:15:10 -07:00
Kartik K. Agaram e2b6baf1ca dithering ppm files using all 256 colors
Not quite working yet, but yields an interesting 'sketching-like'
effect.
2021-07-13 23:58:10 -07:00
Kartik K. Agaram 169e021cc3 scaling the palette working on third attempt
See commits b4e997adb8 and 2777479a94. This seems like a good sign that
dithering is now extremely precise.
2021-07-13 23:57:22 -07:00
Kartik K. Agaram 272432ce75 get rid of our ugly rounding code
It turns out "truncating" the last 4 bits is actually more accurate,
because it divides up the palette evenly. Before:

  0-7 -> 0
  8-0x17 -> 1
  0x18-0x27 -> 2
  ...
  0xd8-0xe7 -> 0xe
  0xe8-0xff -> 0xf

The first interval is just 8 shades, and the final interval is 24
shades.
2021-07-13 17:00:55 -07:00
Kartik K. Agaram 62a2afe0d8 clean up some unseemly speckles
Turns out they were a bug after all, and scaling the palette was just
making them more obvious. The bug: I was carefully clamping to 0xf0 to
avoid rounding later, but I forgot to do so for values between 0xf0 and
0xff. As a result, some values could round up past 0xff and turn black.
2021-07-13 16:59:19 -07:00
Kartik K. Agaram 42bb0922fe cleanup 2021-07-13 13:36:15 -07:00
Kartik K. Agaram bee126654f give up on .pgm files with color depths != 255
Things kinda seem to work for color depths close to 255, but it isn't
really the goal here, and I don't have the skills of numerical analysis
to track this down.
2021-07-13 13:32:54 -07:00
Kartik K. Agaram 96bf3700fd undo 2021-07-13 13:22:56 -07:00
Kartik K. Agaram b4e997adb8 experiment
Now scaling pixels to 255 levels looks a lot better. Still worse,
though. On both t.pgm and barbara.pgm.
2021-07-13 13:22:42 -07:00
Kartik K. Agaram 1004372711 now t.pgm looks right 2021-07-13 13:07:13 -07:00
Kartik K. Agaram 840f394f19 clamp the upper bound of nearest-color as well
I'd kinda convinced myself it would never happen, but observations say
otherwise. Unless there's a bug elsewhere..
2021-07-13 13:04:48 -07:00
Kartik K. Agaram 1394e62813 . 2021-07-13 12:32:03 -07:00
Kartik K. Agaram b1cf56f7af . 2021-07-13 12:18:27 -07:00
Kartik K. Agaram 59732e2ba9 finally a clue: error is going over 255
Exactly in the places to the right of the line.
2021-07-13 06:47:58 -07:00
Kartik K. Agaram 250de0442b undo 2021-07-13 05:23:53 -07:00
Kartik K. Agaram 2777479a94 experiment: scaling pixels to 255 levels
This is strictly worse than before, both with barbara.pgm and more
subtly with t.pgm.
2021-07-13 05:19:00 -07:00
Kartik K. Agaram 23330d06c7 .
Undo commit 70a03be0d0 and reinline the helper extracted there.

I have a better sense now of the primitives to reuse between greyscale
and color dithering.

https://merveilles.town/@akkartik/106571585137582228
2021-07-12 22:53:27 -07:00
Kartik K. Agaram a4f36d60ef more precise error-diffusion
The Barbara test image has been looking right since commit 430dd67cb2.
However, t.pgm has not. This doesn't fix it, but does seem like an
improvement.

The remaining error seems to be unrelated to rounding. Adding 8 more
bits of precision has no effect.
2021-07-12 00:59:36 -07:00
Kartik K. Agaram 4e5e887e01 . 2021-07-12 00:16:02 -07:00
Kartik K. Agaram b646d24b06 . 2021-07-11 15:43:58 -07:00
Kartik K. Agaram 9c4a381770 . 2021-07-11 15:35:55 -07:00
Kartik K. Agaram c76ac49f8f forget HSL conversion for now, stick to RGB
It looks like seeking the nearest neighbor in HSL space leads to more
saturated colors.
2021-07-11 15:31:15 -07:00
Kartik K. Agaram e8b8584796 .
Inline a helper.
2021-07-11 11:42:10 -07:00
Kartik K. Agaram 70a03be0d0 .
Extract a helper.
2021-07-11 09:25:24 -07:00
Kartik K. Agaram 7e21abe0c9 .
Inline an unnecessary block.
2021-07-11 09:18:47 -07:00
Kartik K. Agaram 5234ba60f5 . 2021-07-11 09:16:46 -07:00
Kartik K. Agaram 598fe88ebb . 2021-07-11 03:47:15 -07:00
Kartik K. Agaram 430dd67cb2 dither 256-level greyscale to 8-level greyscale 2021-07-11 03:14:17 -07:00
Kartik K. Agaram eb6cee6022 . 2021-07-10 21:15:51 -07:00
Kartik K. Agaram e1dc0e8250 . 2021-07-10 20:37:21 -07:00
Kartik K. Agaram a97a7cb8c4 . 2021-07-10 20:10:30 -07:00
Kartik K. Agaram 80023c3e54 . 2021-07-10 20:03:16 -07:00
Kartik K. Agaram b28a31315e increase precision for dithering computations
Now we get a perfect checkerboard pattern.
2021-07-10 19:56:32 -07:00
Kartik K. Agaram 3420f10f18 .
https://merveilles.town/@akkartik/106559551043772522
2021-07-10 19:47:32 -07:00
Kartik K. Agaram e377991a9e .
https://merveilles.town/@akkartik/106557664535993377
2021-07-10 11:18:47 -07:00
Kartik K. Agaram 5f8a8c11a2 dithering greyscale using black/white
Starting to look right.
2021-07-10 10:51:39 -07:00
Kartik K. Agaram 2a0f6cbb6f reorder a few functions 2021-07-08 17:08:34 -07:00