visual-comparison


Namevisual-comparison JSON
Version 1.0.3 PyPI version JSON
download
home_pagehttps://github.com/BASILAHAMED/visual-comparison
SummaryImage Comparison Tool
upload_time2024-07-10 10:06:52
maintainerNone
docs_urlNone
authorBasil Ahamed
requires_pythonNone
licenseMIT
keywords visual compare image diff testing
VCS
bugtrack_url
requirements numpy opencv-python scikit-image
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![logo-trans](https://github.com/BASILAHAMED/visual-comparison/raw/main/logo.png)

[![PyPI version](https://badge.fury.io/py/visual-comparison.svg)](https://badge.fury.io/py/visual-comparison)
![Python](https://img.shields.io/badge/Python-Selenium-blue)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/BASILAHAMED/visual-comparison/pulls)
[![License](https://img.shields.io/github/license/BASILAHAMED/visual-comparison.svg)](https://github.com/BASILAHAMED/visual-comparison/blob/main/LICENSE)

## About
Developed with 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. [Selenium-Reference](https://github.com/BASILAHAMED/visual-testing.git)

**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. 

## Usage

#### Installation
```python
pip install visual-comparison
```
## Configuration

All these methods can be combined based on your requirements.
| *Method* | *Description* |
| --- | --- |
| `read_image` | Function to read image from the specified path. This can load both expected and actual images that need to be compared.  |
| `compare_images` | Function to compare two images. This function takes three arguments: `expected_image`, `actual_image`, and `result_destination`. It highlights the differences between the images with red rectangles. |
| `check_match` | Function to check if two images match. This function takes two arguments: `expected_image` and `actual_image`. It returns `true` if both images are identical. |
| `check_mismatch` | Function to check if two images do not match. This function takes two arguments: `expected_image` and `actual_image`. It returns `true` if the images are different. |

## To compare two images through visual-comparison module

#### 1. Sample Code to get Similarity Index:

[Get Similarity Index](https://github.com/BASILAHAMED/visual-comparison/blob/main/get_similarity_index.py)

```python
    # Using ImageComparisonUtil to get similarity index and save output image as result.png
    # Load images to be compared
    expected_image = ImageComparisonUtil.read_image("expected.png")
    actual_image = ImageComparisonUtil.read_image("actual.png")
    
    # Provide the path to save output image
    result_destination = "result.png"
    
    # Compare the images, print the similarity index 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](https://github.com/BASILAHAMED/visual-comparison/blob/main/asserting_match.py)

```python
    # Using ImageComparisonUtil
    # Load images to be compared
    expected_image = ImageComparisonUtil.read_image("expected.png")
    actual_image = ImageComparisonUtil.read_image("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](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/basic%20comparison/expected.png)

### Actual Image
![actual](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/basic%20comparison/actual.png) 

### Result
![result](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/basic%20comparison/result.png)


2. Demo shows how **`colour comparison`** works.
### Expected Image
![expected](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/colour%20comparison/expected.jpg)

### Actual Image
![actual](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/colour%20comparison/actual.png)

### Result
![result](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/colour%20comparison/result.png)

### Support and Contributions
If you find this project useful, please consider giving it a star! ⭐ Your support is greatly appreciated. If you have any ideas for improvements or would like to contribute, we welcome your input and collaboration. Feel free to open an issue or submit a pull request. Thanks for your support!


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/BASILAHAMED/visual-comparison",
    "name": "visual-comparison",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "visual compare image diff testing",
    "author": "Basil Ahamed",
    "author_email": "sbasil.ahamed@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/96/f4/c4c55b26bdc0f827aca10f11f9e31764935c3995fcc465ef1acdb81bea63/visual_comparison-1.0.3.tar.gz",
    "platform": null,
    "description": "![logo-trans](https://github.com/BASILAHAMED/visual-comparison/raw/main/logo.png)\r\n\r\n[![PyPI version](https://badge.fury.io/py/visual-comparison.svg)](https://badge.fury.io/py/visual-comparison)\r\n![Python](https://img.shields.io/badge/Python-Selenium-blue)\r\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/BASILAHAMED/visual-comparison/pulls)\r\n[![License](https://img.shields.io/github/license/BASILAHAMED/visual-comparison.svg)](https://github.com/BASILAHAMED/visual-comparison/blob/main/LICENSE)\r\n\r\n## About\r\nDeveloped with 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. [Selenium-Reference](https://github.com/BASILAHAMED/visual-testing.git)\r\n\r\n**Key Features:**\r\n\r\n* Utilizes standard Python language and specific modules for implementation.\r\n* Generates an output comprising copies of the 'actual' images, with discrepancies delineated by red rectangles.\r\n* 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. \r\n\r\n## Usage\r\n\r\n#### Installation\r\n```python\r\npip install visual-comparison\r\n```\r\n## Configuration\r\n\r\nAll these methods can be combined based on your requirements.\r\n| *Method* | *Description* |\r\n| --- | --- |\r\n| `read_image` | Function to read image from the specified path. This can load both expected and actual images that need to be compared.  |\r\n| `compare_images` | Function to compare two images. This function takes three arguments: `expected_image`, `actual_image`, and `result_destination`. It highlights the differences between the images with red rectangles. |\r\n| `check_match` | Function to check if two images match. This function takes two arguments: `expected_image` and `actual_image`. It returns `true` if both images are identical. |\r\n| `check_mismatch` | Function to check if two images do not match. This function takes two arguments: `expected_image` and `actual_image`. It returns `true` if the images are different. |\r\n\r\n## To compare two images through visual-comparison module\r\n\r\n#### 1. Sample Code to get Similarity Index:\r\n\r\n[Get Similarity Index](https://github.com/BASILAHAMED/visual-comparison/blob/main/get_similarity_index.py)\r\n\r\n```python\r\n    # Using ImageComparisonUtil to get similarity index and save output image as result.png\r\n    # Load images to be compared\r\n    expected_image = ImageComparisonUtil.read_image(\"expected.png\")\r\n    actual_image = ImageComparisonUtil.read_image(\"actual.png\")\r\n    \r\n    # Provide the path to save output image\r\n    result_destination = \"result.png\"\r\n    \r\n    # Compare the images, print the similarity index and save it as result.png\r\n    similarity_index = ImageComparisonUtil.compare_images(expected_image, actual_image, result_destination)\r\n    print(\"Similarity Index:\", similarity_index)\r\n```\r\n\r\n#### 2. Sample Code to assert match/mismatch:\r\n\r\n[Assert Match/Mismatch](https://github.com/BASILAHAMED/visual-comparison/blob/main/asserting_match.py)\r\n\r\n```python\r\n    # Using ImageComparisonUtil\r\n    # Load images to be compared\r\n    expected_image = ImageComparisonUtil.read_image(\"expected.png\")\r\n    actual_image = ImageComparisonUtil.read_image(\"actual.png\")\r\n    \r\n    # Asserting both images\r\n    match_result = ImageComparisonUtil.check_match(expected_image, actual_image)\r\n    assert match_result\r\n```\r\n\r\n## Demo\r\n1. Demo shows how **`basic image comparison`** works.\r\n\r\n### Expected Image\r\n![expected](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/basic%20comparison/expected.png)\r\n\r\n### Actual Image\r\n![actual](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/basic%20comparison/actual.png) \r\n\r\n### Result\r\n![result](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/basic%20comparison/result.png)\r\n\r\n\r\n2. Demo shows how **`colour comparison`** works.\r\n### Expected Image\r\n![expected](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/colour%20comparison/expected.jpg)\r\n\r\n### Actual Image\r\n![actual](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/colour%20comparison/actual.png)\r\n\r\n### Result\r\n![result](https://github.com/BASILAHAMED/visual-comparison/raw/main/sample_images/colour%20comparison/result.png)\r\n\r\n### Support and Contributions\r\nIf you find this project useful, please consider giving it a star! \u2b50 Your support is greatly appreciated. If you have any ideas for improvements or would like to contribute, we welcome your input and collaboration. Feel free to open an issue or submit a pull request. Thanks for your support!\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Image Comparison Tool",
    "version": "1.0.3",
    "project_urls": {
        "Homepage": "https://github.com/BASILAHAMED/visual-comparison"
    },
    "split_keywords": [
        "visual",
        "compare",
        "image",
        "diff",
        "testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4da785d42ab0f70643af8f15b0e99390c6cbf5266571f7883b976082be67042f",
                "md5": "2ca2c49097a0ceb2c91d780c3cc4f099",
                "sha256": "1421325c5f9be73673ff0a0137c7fcdf5656f9cd25ab753e8659cb9b00c91549"
            },
            "downloads": -1,
            "filename": "visual_comparison-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2ca2c49097a0ceb2c91d780c3cc4f099",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5609,
            "upload_time": "2024-07-10T10:06:51",
            "upload_time_iso_8601": "2024-07-10T10:06:51.349921Z",
            "url": "https://files.pythonhosted.org/packages/4d/a7/85d42ab0f70643af8f15b0e99390c6cbf5266571f7883b976082be67042f/visual_comparison-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "96f4c4c55b26bdc0f827aca10f11f9e31764935c3995fcc465ef1acdb81bea63",
                "md5": "0e37c835e96cf91b29a05c58d9aa0c02",
                "sha256": "d83beedbcb2794ef9785db211f81b6db7d5a60578bc597e71fdca97daa970a3d"
            },
            "downloads": -1,
            "filename": "visual_comparison-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "0e37c835e96cf91b29a05c58d9aa0c02",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5521,
            "upload_time": "2024-07-10T10:06:52",
            "upload_time_iso_8601": "2024-07-10T10:06:52.956608Z",
            "url": "https://files.pythonhosted.org/packages/96/f4/c4c55b26bdc0f827aca10f11f9e31764935c3995fcc465ef1acdb81bea63/visual_comparison-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-10 10:06:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "BASILAHAMED",
    "github_project": "visual-comparison",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.26.4"
                ]
            ]
        },
        {
            "name": "opencv-python",
            "specs": [
                [
                    "==",
                    "4.9.0.80"
                ]
            ]
        },
        {
            "name": "scikit-image",
            "specs": [
                [
                    "==",
                    "0.23.1"
                ]
            ]
        }
    ],
    "lcname": "visual-comparison"
}
        
Elapsed time: 0.31055s