Skip to content

Fix Blurhash approximation mode artifacts with lookup table #71

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

Merged
merged 10 commits into from
Apr 22, 2025

Conversation

Rahiche
Copy link
Collaborator

@Rahiche Rahiche commented Apr 20, 2025

Fixes #70

I made a simple demo app to visually compare all possible results for a single image. While researching the topic, I discovered that the lookup table method is even faster with only slightly more memory usage. The new implementation creates a single lookup table with all possible results instead of performing expensive operations each time.
The current approximation method using square roots was causing visible artifacts in the decoded images. By switching to a lookup table with interpolation, we get both improved quality and better performance.

Before (approximation model):

Screenshot 2025-04-20 at 18 53 58

After (lookup table model):

Screenshot 2025-04-20 at 18 52 22

The demo app is not required to be part of the PR but will be helpful for easy visual testing

@Rahiche
Copy link
Collaborator Author

Rahiche commented Apr 20, 2025

@mark8044 try it and let us know if this fixes the issue for you

just use this branch for testing :

  flutter_blurhash:
    git:
      url: https://github.com/Rahiche/flutter_blurhash.git
      ref: fix/srgb-approximation

@bartekpacia I added a basic smoke test since you added the test folder to the requirements but there were none previously, I updated the workflow to not have --debug option for building because it doesn't exist on flutter 3.27

@Rahiche Rahiche requested a review from bartekpacia April 20, 2025 18:32
@Rahiche Rahiche requested review from bartekpacia and Solido April 20, 2025 19:10
@Solido
Copy link
Member

Solido commented Apr 20, 2025

LGTM. Grid is a nice addition I would just use a different source so we can also check different gradient behaviors (color/contrast) by having precise color zone. Pixel peeping but that's how far we are.

@mark8044
Copy link

mark8044 commented Apr 21, 2025

@Rahiche Hey this looks great and seems to be working wonderfully! Thanks much

EDIT: I don't know if im using it wrong, but it doesn't even seem much darker on approximation. Double win :)

@Rahiche
Copy link
Collaborator Author

Rahiche commented Apr 22, 2025

@mark8044 Awesome, yeah the new method is much faster and more accurate, thanks for reporting the issue as I got to dig deeper into it.
will push an update to this PR today

@Rahiche
Copy link
Collaborator Author

Rahiche commented Apr 22, 2025

Hi @Solido I removed the demo app from this PR as I think it would be better to make a separate PR for the grid demo with more control and options.

This PR seems to solve the main issue reported for now so if you can merge it and release a new version that would be great.

@Solido Solido merged commit 4aae273 into fluttercommunity:master Apr 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New approximation mode has bug
4 participants