Commit Graph

22 Commits

Author SHA1 Message Date
kris
348752dc35 Small tweaks and cleanups 2021-01-12 22:01:49 +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
5ba25e7b9c Opt more! 2021-01-11 23:41:04 +00:00
kris
6b890a9b75 Optimize morer 2021-01-11 22:19:41 +00:00
kris
78660784ff cythonize dither_lookahead, still lots of low-hanging fruit 2021-01-11 20:21:00 +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