jhurliman

jhurliman / VisualImageDiff / 0.1.0

README.md

Overview

Count mismatched pixels and optionally create a visual diff between two PNG images using a perceptual difference threshold.

Usage

Input

ParameterDescription
input_file1URI for the first input image. Must be a PNG image
input_file2URI for the second input image. Must be a PNG image with equal dimensions to the first image
output_file(Optional) URI to write the visual diff to. If this is not specified only diff statistics are returned
threshold(Optional) [0-1] perceptual difference threshold. Defaults to 0.1

Output

ParameterDescription
widthWidth of the input images
heightHeight of the input images
diff_pixelsTotal number of different pixels between the two images
diff_percentPercent of different pixels between the two images
output_file(Optional) URI of the output visual diff image in PNG format

Example Output

expectedactualdiff
1diff

Example

Input:

{
    "input_file1": "data://jhurliman/VisualImageDiff/4a.png",
    "input_file2": "data://jhurliman/VisualImageDiff/4b.png",
    "output_file": "data://jhurliman/VisualImageDiff/diff.png",
    "threshold": 0.05
}

Output:

{
    "diff_percent": 0.19998780866249944,
    "diff_pixels": 36089,
    "height": 412,
    "width": 438,
    "output_file": "data://jhurliman/VisualImageDiff/diff.png"
}