'image similarity algorithm for charts

for automating the tests of a legacy Windows application I need to compare screenshots of charts.

Pixel comparison works fine as long as the Windows session opens with same resolution, DPI, color depth, font size, font family, etc., otherwise the screenshot taken during the test may differ slightly from that recorded during the development of the test.

Therefore, I am looking for a method that allows slight variations and produces a score rather than a boolean.

Started with scaling the retrieved screenshot to match the size of recorded one. Of course, pixel comparison fails.

Then I tried to use SSIM to get a similarity score (used https://github.com/rhys-e/structural-similarity). Definitely it does not work for my case -- see below a simplified experiment.

Any suggestions?

Thanks in advance, Adrian.

SSIM experiments

This is the reference picture:

Black line on white canvas

This one contains a black line slightly above than the reference --> getting 0.9447093986742424

Black line above on white canvas

This one, completely different --> getting 0.9516260505445076 Black scrambling



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source