Skip to content

Developed with Python that compares two images with the same sizes and shows the differences visually by drawing rectangles. Useful for visual regression ui automation testings.

License

Notifications You must be signed in to change notification settings

BASILAHAMED/visual-comparison

Repository files navigation

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 programmatically

1. To get similarity index:

    # 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")
    
    # Where to save the result 
    result_destination = "result.png"
    
    # Compare the images and save result.png
    similarity_index = ImageComparisonUtil.compare_images(expected_image, actual_image, result_destination)
    print("Similarity Index:", similarity_index)

2. To 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")
    
    # Where to save the result 
    result_destination = "result.png"
    
    # Asserting both images
    match_result = ImageComparisonUtil.check_match(expected_image, actual_image)
    assert match_result

Demo

  1. Demo shows how 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

Releases

No releases published

Packages

No packages published

Languages