Skip to content

Add support for imagehash for improver acceptance image testing #2106

@cpelley

Description

@cpelley

Background

The imagehash library helps compare images by converting them into a series of numbers (hashes). It then measures how different these hashes are using a method called Hamming distance. If the hashes are similar, the images are likely similar too.

The imagehash approach is tolerant of minor differences because it focuses on the overall structure and patterns in the images rather than every tiny detail. When images are converted into hashes, small changes like slight rotations, color variations, or minor noise don't significantly alter the hash. This means that even if two images aren't exactly the same, their hashes can still be very similar, allowing the method to recognize them as alike.

See here from the official documentation.

IMPROVER acceptance testing methodology (current)

As per improver_tests/acceptance/acceptance.py, a SHA256 value is calculated using hashlib.sha256 for files that are output by the acceptance tests. This sha is compared with a lookup (improver_tests/acceptance/SHA256SUMS).
A tolerant comparison is also made using the improver/utilities/compare.py::compare_netcdfs
Checksums checks are only ignored if environment variable IGNORE_CHECKSUMS is set as "true".

IMPROVER related documentation here.

Imagehash

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions