Skip to main content

Crate blazediff_interpret

Crate blazediff_interpret 

Source
Expand description

Structured region analysis: given two images and a set of changed regions, describe what changed in each one.

The classifier is deliberately separate from whatever found the regions. blazediff finds them by connected components over a pixel-diff mask, blazediff-ssim can find them by thresholding a score map, and a caller can simply supply them — DOM rectangles, a JS-side diff, anything. All three get identical per-pixel classification, because a coarse region is refined against the source pixels before any statistic is computed.

use blazediff_interpret::{interpret, types::BoundingBox, ChangeSource};
let result = interpret(&a, &b, ChangeSource::Regions(&[BoundingBox { x: 8, y: 8, width: 16, height: 16 }]))?;
println!("{}", result.summary);

Re-exports§

pub use types::BoundingBox;
pub use types::ChangeRegion;
pub use types::ChangeSeverity;
pub use types::InterpretResult;

Modules§

types

Structs§

ChangeDensity
YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. How much of any rectangle differs between the two images at all, answered in constant time from a summed-area table.
ComponentInfo
YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits.

Enums§

ChangeSource
Where the change information came from.
InterpretError
Why a set of regions could not be interpreted.

Functions§

build_summary
classify_region
Classify a known change region against a provided full-image change mask.
classify_regions
Classify multiple known regions, then run the same shift relabeling pass used by interpret() so classifier-only verification can evaluate final labels.
classify_severity
Classify severity from diff percentage.
detect_regions
YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. Full region detection pipeline: binary mask → morph close → connected components → extract with original mask
detect_shifts
Post-classification pass: find region pairs where the content that left one location in img1 is the content that appeared at another location in img2, and relabel both halves Shift.
extract_change_mask
YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. Extract change mask from output image: a pixel is changed if it’s not grayscale (R != G or R != B).
interpret
Describe what changed between two images.
interpret_diff
Run a pixel diff and interpret it, optionally keeping the visualization.
mask_options
The DiffOptions a diff must run with for ChangeSource::Diff to be able to recover its mask.
merge_overlapping_components
YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. YIQ squared-delta floor for treating a pixel as actually changed. 100.0 corresponds to a YIQ-weighted distance of 10, roughly equivalent to a perceptual delta of ~0.017 — filters near-identical pixels without throwing away genuine edits. Merge components whose bounding boxes overlap (or sit within slack pixels of each other) into single regions. Fragmented detections — an inpainted photo region shattered into dozens of patches by the diff — have heavily interleaved bboxes, while genuinely separate changes do not, so bbox proximity is a reliable merge criterion where a larger morphological radius would bridge unrelated regions across background.
recolor_output
Repaint a mask-coloured visualization in the caller’s palette.
regions_from_score_map
Turn a lower-resolution scalar score map into regions in image coordinates.