Giter Club home page Giter Club logo

diff_image's Introduction

diff_image

A Dart Package to get the % difference between two images of the same width and height.

diff_image is a Dart version of this with changes on visualization and , you guessed it, the language.

Example

A simple usage example:

import 'package:diff_image/diff_image.dart';
import 'package:image/image.dart';

final FIRST_IMAGE = 'https://raw.githubusercontent.com/nicolashahn/diffimg/master/images/mario-circle-cs.png';
final SECOND_IMAGE = 'https://raw.githubusercontent.com/nicolashahn/diffimg/master/images/mario-circle-node.png';

void foo() async {
  try {
      var diff = await DiffImage.compareFromUrl(
        FIRST_IMAGE,
        SECOND_IMAGE,
      );
      print('The difference between images is: ${diff.value} %');
  } catch(e) {
      print(e);
  }
}

void goo(Image first, Image second) {
  try {
    var diff = DiffImage.compareFromMemory(
      first,
      second,
    );
    print('The difference between images is: ${diff.diffValue} %');
  } catch(e) {
    print(e);
  }
}

main() {
  foo();
  /*These can be obtained with any method*/
  Image first;
  Image second;
  // Here is posible to manipulate both images before passing them
  // to the function.
  goo(first, second);
}

A more detailed example can be found here

Features

  1. Currently there is support for comparing images fetched from urls and from memory or storage.
  2. The compareFromUrl definition is:
  static Future<DiffImgResult> compareFromUrl(
    dynamic firstImgSrc,
    dynamic secondImgSrc, {
    bool asPercentage = true,
    bool ignoreAlpha = true,
  }) async{...}
  1. And the compareFromMemory definition is:
  static DiffImgResult compareFromMemory(
    Image firstImg,
    Image secondImg, {
    bool asPercentage = true,
    bool ignoreAlpha = true,
  }) {...}

where:

  • ignoreAlpha allows to decide whether to take alpha from RGBA into account for the calculation
  • asPercentage set the format of the output (as percentage or between 0-1)

Both methods return an DiffImgResult, a model which contains two elements: An image showing the differences between both images and the numeric value representing the difference (as percentage or not).

  1. A function called saveDiffImg which saves a png showing the differences between firstImg and secondImg (currently not available on Dart Web).

Sample Results

First Image

flutter_logo

Second Image

android_logo

Difference Percentage

With Alpha : 35.67169421487167 %

Without Alpha : 34.83905183744361 %

Difference Image

DiffImg

Suggestions and bugs

Please file feature requests, suggestions and bugs at the issue tracker.

diff_image's People

Contributors

limonadev avatar kevin301099 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.