Skip to main content

Crate resamplescope

Crate resamplescope 

Source
Expand description

Reverse-engineer the resampling filter used by any image resizer.

Port of ResampleScope by Jason Summers (~1400 lines of C, GPL-3.0-or-later). The original tool generates test PNG images, has the resizer process them externally, then reconstructs the filter kernel shape from the output.

This port replaces that file-based workflow with a callback API: you provide a resize closure, and the crate handles everything in-memory. It adds scoring against reference filters, SSIM comparison against perfect reference weight tables, and edge handling detection.

§License

AGPL-3.0-or-later. See LICENSE.

§Original work

This crate is a derivative work. The test pattern generation and filter reconstruction algorithms are ported from the original C source.

§Filter implementations

The reference filter math in filters and the separable 2D resize in [reference] use standard mathematical definitions (sinc, Mitchell-Netravali, etc.) and standard resampling algorithms. The authoritative, optimized implementations of these filters live in imageflow by Imazen.

Re-exports§

pub use analyze::FilterCurve;
pub use edge::EdgeMode;
pub use filters::KnownFilter;
pub use reference::PixelWeights;
pub use reference::WeightEntry;
pub use score::FilterScore;
pub use pattern::generate_dot_pattern;
pub use pattern::generate_line_pattern;
pub use reference::compute_weights;
pub use reference::perfect_resize;
pub use score::ssim;

Modules§

analyze
edge
filters
graph
pattern
reference
score

Structs§

AnalysisConfig
Configuration for analysis.
AnalysisResult
Complete analysis result from probing a resizer.

Enums§

Error
Error type for analysis operations.

Functions§

analyze
Run both downscale and upscale analysis, score against known filters, and optionally detect edge handling.
analyze_downscale
Run only the downscale analysis (dot pattern, 557->555).
analyze_upscale
Run only the upscale analysis (line pattern, 15->555).

Type Aliases§

ResizeFn
The resize callback type: takes a grayscale source image and target dimensions, returns the resized grayscale image.