Skip to main content

Image Comparison Tool

Project description

logo-trans

About

Developed in Python utilizing the OpenCV library, this program compares two images of identical sizes, visually highlighting their differences by drawing red rectangles. Offering flexibility for various automation Quality Assurance (QA) tests, especially visual regression testing.

Key Features:

  • Utilizes standard Python language and specific modules for implementation.
  • Generates an output comprising copies of the 'actual' images, with discrepancies delineated by red rectangles.
  • This tool serves as a valuable asset for automated visual regression testing, facilitating precise visual comparisons to ensure the integrity and accuracy of image-based applications.

Release Notes

Read through RELEASE_NOTES.

Usage

Modules Required

numpy
opencv-python
scikit-image

To compare two images through visual-comparison module

1. Sample Code to get Similarity Index:

Get Similarity Index

    # Using ImageComparisonUtil to get similaity index and compared output image
    # Load images to be compared
    expected_image = ImageComparisonUtil.read_image_from_resources("expected.png")
    actual_image = ImageComparisonUtil.read_image_from_resources("actual.png")
    
    # Where to save the result 
    result_destination = "result.png"
    
    # Compare the images and save it as result.png
    similarity_index = ImageComparisonUtil.compare_images(expected_image, actual_image, result_destination)
    print("Similarity Index:", similarity_index)

2. Sample Code to assert match/mismatch:

Assert Match/Mismatch

    # Using ImageComparisonUtil
    # Load images to be compared
    expected_image = ImageComparisonUtil.read_image_from_resources("expected.png")
    actual_image = ImageComparisonUtil.read_image_from_resources("actual.png")
    
    # Asserting both images
    match_result = ImageComparisonUtil.check_match(expected_image, actual_image)
    assert match_result

Demo

  1. Demo shows how basic image comparison works.

Expected Image

expected

Actual Image

actual

Result

result

  1. Demo shows how colour comparison works.

Expected Image

expected

Actual Image

actual

Result

result

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

visual_comparison-1.0.2.7.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

visual_comparison-1.0.2.7-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page