Commit Graph

206 Commits

Author SHA1 Message Date
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
4984df7f7a Tidy up and optimize a bit 2021-07-19 13:21:32 +01:00
kris
e08f25e4cc Simplify 2021-07-19 12:55:50 +01:00
kris
20a73ffb8a Checkpoint - working again, and simpler 2021-07-19 12:33:49 +01:00
kris
508ce134aa Try to fix how we compute the next pixel palette for 8-bit mode.
Still not sure this is correct.
2021-07-19 09:58:22 +01:00
kris
70074a2942 Support arbitrary gamma correction of input image 2021-07-19 09:57:26 +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
9bbb9fda7c Fix typos in x transition labels 2021-07-15 09:41:57 +01:00
kris
a593639606 Allow parametrizing gamma 2021-05-28 11:24:05 +01:00
kris
07a358d49b Fix --all to be an optional boolean argument, and fix a deprecation warning (h/t: 4am) 2021-03-15 21:42:21 +00:00
kris
fb6a0f90ab whitespace 2021-03-15 21:42:01 +00:00
kris
99242d455f Fix warning 2021-03-15 21:41:39 +00:00
kris
7a7923503f With recent optimizations converter became ~2.1x faster, so
--lookahead=8 is a reasonable new default.
2021-03-15 17:55:21 +00:00
kris
5487b4aa7e Note disk space requirements and tweak usage 2021-03-15 17:50:56 +00:00
kris
527f6504f7 Add comments and tidy up some more 2021-03-15 17:22:14 +00:00
kris
101d974d50 Use hyphens in option names so that --no-boolean-option is
consistently hyphenated.
2021-03-15 17:21:22 +00:00
kris
ede063a21b No need to pattern to have third axis of shape 1
Minor optimization to not compute error_fraction 3 times

Tidy a bit
2021-03-15 16:22:55 +00:00
kris
551be3eba7 Get --resolution=140 working again
Back out the pixel_palette_options WIP to make this mergable
2021-03-15 15:41:33 +00:00
kris
fcf83aaf9c Even more fasterer! 2021-03-15 15:11:06 +00:00
kris
f157272327 Checkpoint more type annotations 2021-03-15 15:10:49 +00:00
kris
722e85f645 Combine loops in dither_lookahead and don't bother dithering beyond
lookahead or edge of screen.
2021-03-15 15:10:33 +00:00
kris
8b48455c8f Checkpoint 2021-03-15 15:10:33 +00:00
kris
049c334950 Fixed 2021-03-15 15:10:33 +00:00
kris
f4cc7dac40 Checkpoint - I broke something 2021-03-15 15:10:33 +00:00
kris
a686ef76c3 WIP 2021-03-15 15:10:12 +00:00
kris
f87ca90fd4 Add a --verbose option to output progress 2021-03-15 15:01:21 +00:00
kris
e98116b276 Tidy up for merge 2021-03-15 14:01:14 +00:00
kris
72de8f0dfe Try using a table 2021-03-15 13:55:44 +00:00
kris
4ddd48ed8c Try to fix image layout 2021-03-15 13:43:25 +00:00
kris
85ad76a251 More fixes 2021-03-15 13:41:01 +00:00
kris
aa802b93d4 Fixes 2021-03-15 13:35:17 +00:00
kris
5f78cf53d3 Fixes 2021-03-15 13:33:07 +00:00
kris
4b00da3771 Add more screenshots of --palette=openemulator
Rename files for consistency
2021-03-15 13:08:34 +00:00
kris
93456edb53 Openemulator screenshots of NTSC image conversions 2021-03-15 12:07:59 +00:00
kris
d5e6038939 Regen 2021-03-15 11:50:51 +00:00
kris
aef135808c Rename files to match existing scheme 2021-03-15 11:05:56 +00:00
kris
61052ca93c Add DHR and preview images rendered with --palette=ntsc 2021-03-15 10:59:04 +00:00
kris
e1108b4dd0 Tidy up a bit in preparation for merge. 2021-03-15 10:45:57 +00:00
kris
467a0cd196 Tidy up a bit to prepare for merge 2021-03-15 10:45:33 +00:00
kris
d5bd173345 Update to describe NTSC emulation 2021-02-18 00:53:43 +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
301ca2772b Checkpoint 2021-02-04 22:00:03 +00:00
kris
3ac5c284e9 Checkpoint NTSC emulation 2021-02-03 23:40:16 +00:00
kris
a835baadf8 Fix --show_input 2021-01-26 00:16:51 +00:00
kris
b29f5f2b18 Create directory before writing to it 2021-01-25 23:57:07 +00:00
kris
c3c88efc09 Fix path typos 2021-01-25 23:42:17 +00:00
kris
2bbd65a079 Add some comments and docstrings 2021-01-25 23:16:46 +00:00