All Projects → romankh3 → Image Comparison

romankh3 / Image Comparison

Licence: apache-2.0
Published on Maven Central and jCenter Java Library that compares 2 images with the same sizes and shows the differences visually by drawing rectangles. Some parts of the image can be excluded from the comparison. Can be used for automation qa tests.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Image Comparison

Lib9wada
Wonderful library with lots of useful functions, algorithms and data structures in C, link it with -l9wada
Stars: ✭ 35 (-75.86%)
Mutual labels:  algorithms, library
Functionalplus
Functional Programming Library for C++. Write concise and readable C++ code.
Stars: ✭ 1,286 (+786.9%)
Mutual labels:  algorithms, library
Angular Tree Component
A simple yet powerful tree component for Angular (>=2)
Stars: ✭ 1,031 (+611.03%)
Mutual labels:  opensource, library
D3 Spotmatrix
Open Source Javascript Library to render Spot Matrix Charts using D3.js
Stars: ✭ 12 (-91.72%)
Mutual labels:  comparison, opensource
Angular Open Source Starter
This is a starter project for creating open-source libraries for Angular. It is a full fledged Angular workspace with demo application and easy library addition. It is designed to be used for open-sourcing libraries on Github and has everything you'd need ready for CI, code coverage, SSR testing, StackBlitz demo deployment and more.
Stars: ✭ 120 (-17.24%)
Mutual labels:  opensource, library
Candyview
Implement any RecyclerView in just 1 Line. CandyView handles everything for you.
Stars: ✭ 15 (-89.66%)
Mutual labels:  gradle, library
Litiv
C++ implementation pool for computer vision R&D projects.
Stars: ✭ 82 (-43.45%)
Mutual labels:  algorithms, library
Let
Annotation based simple API flavored with AOP to handle new Android runtime permission model
Stars: ✭ 532 (+266.9%)
Mutual labels:  gradle, library
Liquidrefreshlayout
Liquid Refresh Layout is a simple SwipeToRefresh library that helps you easily integrate SwipeToRefresh and performs simple clean liquid animation
Stars: ✭ 114 (-21.38%)
Mutual labels:  gradle, library
Competitive Programming
Hello Programmers 💻 , A one-stop Destination✏️✏️ for all your Competitive Programming Resources.📗📕 Refer CONTRIBUTING.md for contributions
Stars: ✭ 113 (-22.07%)
Mutual labels:  algorithms, opensource
Etl
Embedded Template Library
Stars: ✭ 783 (+440%)
Mutual labels:  algorithms, library
Gradle Maven Plugin
Gradle 5.x Maven Publish Plugin to deploy artifacts
Stars: ✭ 124 (-14.48%)
Mutual labels:  gradle, library
Rando.js
The world's easiest, most powerful random function.
Stars: ✭ 659 (+354.48%)
Mutual labels:  opensource, library
Video To Ascii
It is a simple python package to play videos in the terminal using characters as pixels
Stars: ✭ 960 (+562.07%)
Mutual labels:  opensource, pixel
Ascii art
Real-Time ASCII Art Rendering Library
Stars: ✭ 599 (+313.1%)
Mutual labels:  algorithms, library
Android Camera2 Library
Library to use Android Camera2 api easily.
Stars: ✭ 66 (-54.48%)
Mutual labels:  gradle, library
Weatherview
WeatherView is an Android Library let you make cool weather animations for your app
Stars: ✭ 426 (+193.79%)
Mutual labels:  opensource, library
Competitiveprogramming
A collection of algorithms, data structures and other useful information for competitive programming.
Stars: ✭ 475 (+227.59%)
Mutual labels:  algorithms, library
Cdnjs
🤖 CDN assets - The #1 free and open source CDN built to make life easier for developers.
Stars: ✭ 9,270 (+6293.1%)
Mutual labels:  opensource, library
Downlords Faf Client
Official client for Forged Alliance Forever
Stars: ✭ 121 (-16.55%)
Mutual labels:  gradle, opensource

logo-trans Maven Central Gitter Javadocs Codacy Badge Build Status Coverage Status BCH compliance Bintray PRs Welcome

About

Published on Maven Central and jCenter Java Library that compares 2 images with the same sizes and shows the differences visually by drawing rectangles. Some parts of the image can be excluded from the comparison. Can be used for automation qa tests. The Usages of the image-comparison can be found here Usage Image Comparison

  • Implementation is using only standard core language and platform features, no 3rd party libraries and plagiarized code is permitted.

  • Pixels (with the same coordinates in two images) can be visually similar, but have different values of RGB. 2 pixels are considered to be "different" if they differ more than pixelToleranceLevel(this configuration described below) from each other.

  • The output of the comparison is a copy of actual images. The differences are outlined with red rectangles as shown below.

  • No third party libraries or borrowed code are in usage.

  • Some parts of the image can be excluded from the comparison and drawn in the result image.

Article about growing image-comparison on habr: How did the test task become a production library

Configuration

All these configurations can be updated based on your needs. | Property | Description | | --- | --- | | threshold | The threshold which means the max distance between non-equal pixels. Could be changed according size and requirements to the image. | | rectangleLineWidth | Width of the line that is drawn the rectangle. | | destination | File of the result destination. | | minimalRectangleSize | The number of the minimal rectangle size. Count as (width x height). By default it's 1. | | maximalRectangleCount | Maximal count of the Rectangles, which would be drawn. It means that would get first x biggest rectangles. Default value is -1, that means that all the rectangles would be drawn. | | pixelToleranceLevel | Level of the pixel tolerance. By default it's 0.1 -> 10% difference. The value can be set from 0.0 to 0.99. | | excludedAreas | ExcludedAreas contains a List of Rectangles to be ignored when comparing images. | | drawExcludedRectangles | Flag which says draw excluded rectangles or not. | | fillExcludedRectangles | Flag which says fill excluded rectangles or not. | | percentOpacityExcludedRectangles | The desired opacity of the excluded rectangle fill. | | fillDifferenceRectangles | Flag which says fill difference rectangles or not. | | percentOpacityDifferenceRectangles | The desired opacity of the difference rectangle fill. | | allowingPercentOfDifferentPixels | The percent of the allowing pixels to be different to stay MATCH for comparison. E.g. percent of the pixels, which would ignore in comparison. Value can be from 0.0 to 100.00 |

Release Notes

Can be found in RELEASE_NOTES.

Usage

Maven

<dependency>
    <groupId>com.github.romankh3</groupId>
    <artifactId>image-comparison</artifactId>
    <version>4.3.1</version>
</dependency>

Gradle

compile 'com.github.romankh3:image-comparison:4.3.1'

To compare two images programmatically

Default way to compare two images looks like:
        //load images to be compared:
        BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("expected.png");
        BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("actual.png");

        //Create ImageComparison object and compare the images.
        ImageComparisonResult imageComparisonResult = new ImageComparison(expectedImage, actualImage).compareImages();
        
        //Check the result
        assertEquals(ImageComparisonState.MATCH, imageComparisonResult.getImageComparisonState());
Save result image

To save result image, can be used two ways:

  1. add a file to save to constructor. ImageComparison will save the result image in this case.
        //load images to be compared:
        BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("expected.png");
        BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("actual.png");
        
        // where to save the result (leave null if you want to see the result in the UI)
        File resultDestination = new File( "result.png" );

        //Create ImageComparison object with result destination and compare the images.
        ImageComparisonResult imageComparisonResult = new ImageComparison(expectedImage, actualImage, resultDestination).compareImages();
  1. execute ImageComparisonUtil.saveImage static method
        //load images to be compared:
        BufferedImage expectedImage = ImageComparisonUtil.readImageFromResources("expected.png");
        BufferedImage actualImage = ImageComparisonUtil.readImageFromResources("actual.png");

        //Create ImageComparison object with result destination and compare the images.
        ImageComparisonResult imageComparisonResult = new ImageComparison(expectedImage, actualImage).compareImages();

        //Image can be saved after comparison, using ImageComparisonUtil.
        ImageComparisonUtil.saveImage(resultDestination, resultImage); 

Demo

Demo shows how image-comparison works.

Expected Image

expected

Actual Image

actual

Result

result

Contributing

Please, follow Contributing page.

Code of Conduct

Please, follow Code of Conduct page.

License

This project is Apache License 2.0 - see the LICENSE file for details

Thanks @dee-y for designing this logo

Also if you're interesting - see my other repositories

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].