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

Overly sensitive to minor color variations #9

Open
gnachman opened this issue Mar 2, 2020 · 4 comments
Open

Overly sensitive to minor color variations #9

gnachman opened this issue Mar 2, 2020 · 4 comments

Comments

@gnachman
Copy link

gnachman commented Mar 2, 2020

macOS dithers solid colors in recent OS versions. This is noticeable on 10.15 with a macbook pro in direct sunlight, for example. Furthermore, antialiasing artifacts due to unaligned drawing on a retina display can cause fuzzy edges. Because typometer checks only for exact color equivalence, it often gets tripped up.

I was unable to use it at all on macOS until I made the following changes:

  1. Change BenchmarkImpl.typeSync to consider colors differing by less than 1% to be equal (by summing the difference of the red, green, and blue channels)
  2. Change MetricsDetector.uniformLengthFrom to ignore the 2 least significant bits of each color channel.
@alysbrooks
Copy link

alysbrooks commented Apr 11, 2020

@gnachman Do you have a copy of this version somewhere? It's not a big deal to make these changes myself but if you made them available it might save me half an hour. Thanks!

@gnachman
Copy link
Author

In BenchmarkImpl.typeSync(), replace if (!accessor.getPixelColor((int) round(x), y).equals(metrics.getBackground())) with an approximate equality test (I summed the error in r, g, and b and considered it equal if less than 6).

In MetricsDetector.uniformLengthFrom, replace image.getRGB(x, point.y) != color with an approximation test. I just counted the number of bits that differed, but that's mostly because I was too lazy to figure out how the RGB value was represented in an int :)

@alysbrooks
Copy link

Thanks, @gnachman!

@frarees
Copy link

frarees commented Oct 8, 2020

Check out my fork for an implementation (specifically frarees@0bb2818).

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

No branches or pull requests

3 participants