Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more accurate bit for alpha lookup. #2473

Merged
merged 2 commits into from
Jun 13, 2023

Conversation

JimBobSquarePants
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #2469

Our pixel map accuracy wasn't good enough for alpha comparison, so we were leaving artifacts.

This increases memory from 2.26MB to 4.45MB but not only do we fix our issue, as a result of the increased accuracy, we're also getting less collisions in our RGB components.

/// </para>
/// </remarks>
private unsafe struct ColorDistanceCache : IDisposable
{
private const int IndexBits = 5;
private const int IndexAlphaBits = 5;
private const int IndexAlphaBits = 6;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be zero when TPixel doesn't have an alpha. It might be worth to eventually implement some trick to have two versions of EuclideanPixelMap, so we save memory when working with RGB pngs and gifs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We could easily preserve much more accurate matches in less space.

@JimBobSquarePants JimBobSquarePants merged commit bf43044 into main Jun 13, 2023
@JimBobSquarePants JimBobSquarePants deleted the js/2469-color-LUT-memory branch June 13, 2023 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected artefacts when quantizing images
2 participants