Commit Graph

238 Commits

Author SHA1 Message Date
kris a061795022 Re-enable 140px mode 2021-01-15 22:58:01 +00:00
kris 8d671f08ac Remove bitmap support 2021-01-15 22:34:22 +00:00
kris d57d6f9038 Add flags to show input/output images 2021-01-15 22:34:03 +00:00
kris ce99d62304 Tidy 2021-01-15 22:28:44 +00:00
kris f132f0b84b Default to --lookahead=6 now that it's fast 2021-01-15 22:25:32 +00:00
kris c5b8feb17e Parametrize dither patterns as command-line argument 2021-01-15 22:25:06 +00:00
kris f5553e00b8 Rename 2021-01-15 22:20:28 +00:00
kris 31b565f22a Refactor a bit 2021-01-15 22:18:25 +00:00
kris 0109675bf2 Tidy a bit 2021-01-12 22:22:37 +00:00
kris 348752dc35 Small tweaks and cleanups 2021-01-12 22:01:49 +00:00
kris 02393381df Write out mmapp'ed numpy array instead of pickling 2021-01-12 22:01:29 +00:00
kris ebd9f94d98 Mmap uncompressed distance array instead of bunzipping first. Since
we don't end up reading most of the elements again, this is faster.
2021-01-12 20:44:39 +00:00
kris 45ceb9987f Opt open_image a bit 2021-01-12 10:21:31 +00:00
kris 32d54d5b78 cythonize dither_image 2021-01-12 10:00:56 +00:00
kris 3e7cb37253 Oops, don't use python to cast to long 2021-01-12 00:27:03 +00:00
kris 31446cb457 Minor tweaks 2021-01-11 23:54:00 +00:00
kris 5ba25e7b9c Opt more! 2021-01-11 23:41:04 +00:00
kris 6a4e5995a2 Opt more! 2021-01-11 23:04:47 +00:00
kris 6b890a9b75 Optimize morer 2021-01-11 22:19:41 +00:00
kris 5c07469751 Optimize more! 2021-01-11 21:35:13 +00:00
kris b601360669 Optimize more 2021-01-11 20:56:26 +00:00
kris a40b496a38 Optimize more 2021-01-11 20:43:28 +00:00
kris 78660784ff cythonize dither_lookahead, still lots of low-hanging fruit 2021-01-11 20:21:00 +00:00
kris bbc9eec29f malloc temporary array 2021-01-11 18:55:37 +00:00
kris 575fa168ed Cythonize dither.apply 2021-01-10 22:12:14 +00:00
kris ec691f5d6d Clean up and optimize 2021-01-10 20:10:32 +00:00
kris 61b8171586 Working version with precomputation. 2021-01-10 16:06:14 +00:00
kris 9129e680f5 Add support for euclidean distance in LAB space (though it doesn't
give good results and doesn't seem to be much faster anyway)

Clip RGB values before converting to LAB, to allow more easily
experimenting with not clipping the result of dithering, i.e. allowing
quantization error to take RGB values out of the 0..255 range.  This
may not improve quality but need to do more experiments.
2021-01-09 23:25:46 +00:00
kris db87ad2f9e Working version 2021-01-09 18:05:36 +00:00
kris 6bf7fd90ff WIP - optimizations but also some bugs 2021-01-08 22:44:28 +00:00
kris 8f2424127f Remove debug code 2021-01-04 21:11:18 +00:00
kris 7f47aa33e7 - work with image as numpy.ndarray instead of Image
- use float32 representation instead of uint8
- Vectorize applying dither
- Improve quality of 560px images by looking ahead N pixels,
  evaluating all 2^N colour choices and minimizing the total error.
2021-01-04 21:08:29 +00:00
kris 82e5779a3a Allow modeling screen as 140x192x16 pixels (i.e. ignoring fringing) or
560x192 where each pixel has a choice of two colours.

The latter doesn't give good results currently, it produces long runs
of colour, presumably when the immediate next choice for dithering is
worse than the current one.  i.e. it gets easily stuck in a local
minimum.

Looking ahead N pixels and computing the 2^N options should improve
this.
2021-01-03 23:23:15 +00:00
kris ff7a7365bb - Convert from sRGB to linear RGB when rescaling image, and when
dithering.  This is important for linear treatment of quantization
  errors.

- Implement Jarvis dithering

- Implement CIE2000 perceptual diff for colour matching, and the
  CIR601 luminosity weighting used by bmp2dhr (which might come from
  https://bisqwit.iki.fi/story/howto/dither/jy/ - I can't find any
  other source references for this yet).  The former seems to give
  much better results, although it is also several times slower.

- Switch back to treating the display as 140x192x16 colours,
  i.e. ignoring NTSC colour fringing.

- Add sRGB palettes for Virtual II and OpenEmulator (based on sampling
  screen display when rendering full-screen colour)
2021-01-03 22:32:04 +00:00
kris 2458bf98f7 Pack output in Apple II screen format and save as binary file. 2020-12-30 10:27:33 +00:00
kris 38d621a097 Fix edge conditions in dithering
Add TODOs
2020-12-29 21:03:17 +00:00
kris da420b66c8 Limit colour choices to the two available at each pixel. 2020-12-29 20:47:33 +00:00
kris 5a6eb08db1 Floyd-Steinberg dithering to DHGR colour palette. Doesn't yet take
into account the restrictions on neighbouring colours.
2020-12-29 18:24:29 +00:00