Commit Graph

21 Commits

Author SHA1 Message Date
KrisKennaway 69a96b4719
Optimize palette initialization and NTSC image conversion (#13)
About 2x faster end-to-end with default dhr conversion options
2023-02-26 00:00:39 +00:00
kris df0adec8aa Fix typo 2021-11-02 22:24:47 +00:00
kris d35cdbc877 Switch remaining palettes to be indexed by (n-bit pixel value, NTSC
phase) and update the comments to explain the encoding scheme.
2021-11-02 22:15:13 +00:00
kris 9dbf413733 Tidy 2021-11-02 15:45:20 +00:00
kris b63fd81c07 Unify DHGRScreen implementations 2021-11-02 15:23:23 +00:00
kris 75a3c6bc48 Simplify image_to_rgb and remove the need for DOTS and DOTS_TO_INDEX 2021-11-02 15:14:22 +00:00
kris 0c588f7489 Tidy 2021-07-19 18:40:16 +01:00
kris feefdb5dc6 Use .npy format for RGB to CAM16UCS conversion matrix, and get rid of precomputed CIE2000 distances 2021-07-19 18:35:44 +01:00
kris e979df03bc Nope, don't need XYZ 2021-07-19 18:13:43 +01:00
kris 8b500b16cb Dither in XYZ representation but use CAM16UCS for colour differences.
This gives the best of both worlds: dithering in a linear space, with
good (and fast) perceptual error differences

TBD: would linear RGB work as well as XYZ?
2021-07-19 17:54:46 +01:00
kris e08f25e4cc Simplify 2021-07-19 12:55:50 +01:00
kris 7a3adea025 Try cam16UCS instead 2021-07-15 14:25:32 +01:00
kris 4fcda908bd WIP - use colourspacious to perform image dithering in CAM02_UCS
colour space, which is supposed to be perceptually uniform.  i.e. we
can use Euclidean distance instead of CIEDE2000
2021-07-15 13:58:22 +01:00
kris 467a0cd196 Tidy up a bit to prepare for merge 2021-03-15 10:45:33 +00:00
kris e0b732cdaa Reimplement NTSC conversion to closely match openemulator output. I
can't figure out why contrast=2 is needed (openemulator uses a default
value of 1, so there must be a factor of 2x somewhere), or where the
slight hue rotation comes from - perhaps this is somehow introduced by
the more complex band-pass filtering that openemulator does?

I needed to also account for the DHGR timing difference that
introduces a phase offset of 1 pixel between the memory values and
displayed pixel timings.

Fix a last-minute bug with palette precomputation.
2021-02-17 21:29:43 +00:00
kris e1dab91783 Whitespace 2021-02-14 23:42:57 +00:00
kris ad9515dcf2 Implement NTSC emulation, using an 8 pixel window for chroma signal.
Use this to precompute a new ntsc palette with 256 entries (though
only 84 unique colours) that are available by appropriate pixel
sequences.  Unfortunately the precomputed distance matrix for this
palette is 4GB!

Optimize the precomputation to be less memory hungry, while also
making efficient use of the mmapped output file.

Add support for dithering images using this 8-bit palette depth,
i.e. to optimize for NTSC rendering.  This often gives better image
quality since more colours are available, especially when modulating
areas of similar colour.

Fix 140 pixel dithering and render the output including NTSC fringing
instead of the unrealistic 140px output that doesn't include it.

Add support for rendering output image using any target palette, which
is useful e.g. for comparing how an 8-pixel NTSC rendered image will
be displayed on an emulator using 4-pixel ntsc emulation (there is
usually some colour bias, because the 8 pixel chroma blending tends to
average away colours).

Switch the output binary format to write AUX memory first, which
matches the image format of other utilities.
2021-02-14 23:34:25 +00:00
kris 2bbd65a079 Add some comments and docstrings 2021-01-25 23:16:46 +00:00
kris dd8cf07c49 Add support for multiple palettes 2021-01-25 22:28:00 +00:00
kris a4ecf69610 Checkpoint WIP 2021-01-21 23:17:55 +00:00
kris 31b565f22a Refactor a bit 2021-01-15 22:18:25 +00:00