pavelfatin/typometer

Overly sensitive to minor color variations

gnachman opened this issue · 4 comments

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.

@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!

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 :)

Thanks, @gnachman!

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