Skip to main content

blazediff-interpret

Structured region analysis for image diffs. Given two images and a set of changed regions, it says what changed in each one — not just where.

use blazediff_interpret::{interpret, ChangeSource};

// From a pixel diff — what `blazediff` does.
// `diff` is the `DiffResult` that `blazediff::diff` returned.
let result = interpret(&expected, &actual, ChangeSource::Diff {
    result: &diff,
    output: &diff_image,
})?;

// From a similarity map — what `blazediff-ssim` does.
let result = interpret(&expected, &actual, ChangeSource::ScoreMap {
    map: &outcome.map,
    width: outcome.map_width,
    height: outcome.map_height,
    floor: 0.99,
})?;

// From boxes you already have.
let result = interpret(&expected, &actual, ChangeSource::Regions(&boxes))?;

println!("{}", result.summary);
for region in &result.regions {
    println!("{:?} at {} ({:.2}%)", region.change_type, region.position, region.percentage);
}

Why it's a separate crate

The classifier is deliberately independent of whatever found the regions. Three producers feed it today:

Producer ChangeSource How it finds regions
blazediff Diff connected components over a pixel-diff mask
blazediff-ssim ScoreMap thresholding a local SSIM score map
your code Regions DOM rectangles, a JS-side diff, a crop list — anything

All three call the same function and get identical treatment; only the description of where differs. blazediff and blazediff-ssim are independent of each other, so a classifier living in either would be unreachable from the other. It sits below both instead.

Coarse regions are fine

A producer only has to know roughly where something changed. Before any statistic is computed, the supplied boxes are refined against the source pixels — every pixel whose YIQ delta falls below the noise floor is dropped — so shape, colour and gradient analysis stay per-pixel no matter how blocky the input was. (If a claimed box refines to nothing but the content does differ — a sub-threshold edit such as a subtle uniform recolor — the box is kept as-is so the region still gets meaningful statistics.)

// An 8x8 change, described exactly and then quantized to a 16px grid.
let exact  = interpret(&a, &b, ChangeSource::Regions(&[BoundingBox { x: 16, y: 16, width: 8,  height: 8  }]))?;
let coarse = interpret(&a, &b, ChangeSource::Regions(&[BoundingBox { x: 16, y: 16, width: 16, height: 16 }]))?;
assert_eq!(coarse.diff_count, exact.diff_count); // both 64

That is what makes an SSIM window map a usable region source: its grid is coarse, but the statistics derived from it are not. diff_count therefore means the same thing on every path — actually-changed pixels, never windows.

API

Item Purpose
interpret the entry point: a ChangeSource in, a full InterpretResult out
ChangeSource Diff (a pixel diff's output + counts), ScoreMap (a similarity map), or Regions
classify_region / classify_regions classify against a mask you already hold
detect_regions connected components over a boolean mask
merge_overlapping_components fuse fragmented components whose bboxes overlap or nearly touch
extract_change_mask recover a mask from an RGBA diff visualization
detect_shifts the shift-relabeling pass, for producers holding an exact mask
classify_severity, build_summary the pooling steps, exposed for custom pipelines

Regions arriving from a caller are validated: a box outside the image is an InterpretError::RegionOutOfBounds, not an out-of-bounds panic. That matters now that regions cross the wasm and N-API boundaries.

Python - blazediff-interpret

pip install blazediff-interpret

PyO3 bindings shipped as abi3-py38 wheels for CPython ≥ 3.8 (macOS, Linux manylinux, Windows; arm64 + x86_64). Built from this crate's python Cargo feature.

import blazediff_interpret as interpret

result = interpret.interpret_images("expected.png", "actual.png", "diff.png")
print(result["summary"])
for region in result["regions"]:
    print(region["changeType"], region["bbox"])

# Also: interpret_buffers(bytes, bytes), interpret_ssim(base, compare,
# metric=...) and interpret_regions(base, compare, regions).

The result crosses as a plain dict with camelCase keys, matching the N-API binding and the CLI's --json. interpret_regions takes (x, y, width, height) tuples or mappings with those keys, so a bbox from a prior result feeds straight back in.

What it classifies

Each region gets a change type, a shape, a position, a confidence, and the statistics behind them — colour delta, gradient/edge correlation, luminance correlation, chroma-plane movement (hue rotation, saturation, delta smoothness), fill ratios, and the signals the classifier used. See INTERPRET.md for the full algorithm: pipeline stages, formulas, and classification rules.

License

MIT

Metadata

Release files for blazediff-interpret 7.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for blazediff-interpret 7.1.1
File Actions
blazediff_interpret-7.1.1-cp38-abi3-win_arm64.whl CPython 3.8 abi3 Windows ARM64 Details for blazediff_interpret-7.1.1-cp38-abi3-win_arm64.whl
blazediff_interpret-7.1.1-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for blazediff_interpret-7.1.1-cp38-abi3-win_amd64.whl
blazediff_interpret-7.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for blazediff_interpret-7.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
blazediff_interpret-7.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for blazediff_interpret-7.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
blazediff_interpret-7.1.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for blazediff_interpret-7.1.1-cp38-abi3-macosx_11_0_arm64.whl
blazediff_interpret-7.1.1-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for blazediff_interpret-7.1.1-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 4.1 MB

Release files / blazediff_interpret-7.1.1-cp38-abi3-win_arm64.whl

Download URL blazediff_interpret-7.1.1-cp38-abi3-win_arm64.whl
Size 622.4 kB
Tags CPython 3.8 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
8aaf4c296d5afde0ad6230b109bfc230b3b23badbde3b2bc24aeb68c850ab096
BLAKE2b-256 checksum
How to use checksums
45890c1dd1959ced5662c2bf1ee56135a29f90e9e18dfc02f58f8f9e32316ed9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff_interpret-7.1.1-cp38-abi3-win_amd64.whl

Download URL blazediff_interpret-7.1.1-cp38-abi3-win_amd64.whl
Size 662.8 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
26a2c3cd6acc3ab192ce75be6bbb9781fde70b43b0d5104cb930461940f46d7d
BLAKE2b-256 checksum
How to use checksums
3f73f6728a894258667000e8132ba491132c3a88329ab45dc102d18b7b2ab758
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff_interpret-7.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL blazediff_interpret-7.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 759.5 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e176f444c54e6992b7f089e40110fcf5db93be33980ab55086a1d30f28bee257
BLAKE2b-256 checksum
How to use checksums
0da20884728c490d2fe90b1bad721939cce753036b302555ee34b49c605d1be5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff_interpret-7.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL blazediff_interpret-7.1.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 706.5 kB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
90c04801613ba52df266df5236e28da1f1e4fab066a917c4d26e9a6a71847c57
BLAKE2b-256 checksum
How to use checksums
ab2b25684b9d8a2d97af0b2ce2e9c19c32ce336d8f0961eec483c996a0b86891
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff_interpret-7.1.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL blazediff_interpret-7.1.1-cp38-abi3-macosx_11_0_arm64.whl
Size 644.5 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9df338ca7e28b2016229e82dfe47f70b3c4dc187b8ce41b44833539300aa21f5
BLAKE2b-256 checksum
How to use checksums
a1fa2f157f53565832b099620928d91dcadff6a256c913deaa33cc5ff0a4737d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff_interpret-7.1.1-cp38-abi3-macosx_10_12_x86_64.whl

Download URL blazediff_interpret-7.1.1-cp38-abi3-macosx_10_12_x86_64.whl
Size 687.2 kB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
bcd549eee035c5650bd9d6530bd43ae1c787879f6ac188bb5bfb3dc752be3789
BLAKE2b-256 checksum
How to use checksums
8380f66a26aeee94e4bc98dee61caeaa4719e12ccc1224be95887ef00dab2c54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Security for blazediff-interpret 7.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page