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§
Structs§
- Change
Density - 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.
- Component
Info - 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§
- Change
Source - Where the change information came from.
- Interpret
Error - 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
DiffOptionsa diff must run with forChangeSource::Diffto 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
slackpixels 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.