#image #comparison #labs #nvidia #error #flip #bindings

sys nv-flip-sys

FFI 绑定到 Nvidia Labs 的 ꟻLIP 图像比较和错误可视化库

2 个版本

0.1.1 2023 年 6 月 4 日
0.1.0 2023 年 6 月 4 日

#252 in 可视化

Download history 3923/week @ 2024-03-14 5049/week @ 2024-03-21 3478/week @ 2024-03-28 3285/week @ 2024-04-04 3805/week @ 2024-04-11 4042/week @ 2024-04-18 2839/week @ 2024-04-25 2625/week @ 2024-05-02 1259/week @ 2024-05-09 1625/week @ 2024-05-16 2247/week @ 2024-05-23 3114/week @ 2024-05-30 3291/week @ 2024-06-06 5428/week @ 2024-06-13 2515/week @ 2024-06-20 1504/week @ 2024-06-27

13,043 每月下载量
nv-flip 中使用

(MIT OR Apache-2…

215KB
433

nv-flip

绑定到 Nvidia Labs 的 ꟻLIP 图像比较和错误可视化库。

此库允许您可视化并推理渲染图像之间人类可注意到的差异。尤其是在比较噪声或其它细微差异的图像时,FLIP 的比较可能比简单的像素比较更有意义。

comp

为了保持小的依赖关系,此 crate 依赖于 image,但互操作简单。

示例

// First we load the "reference image". This is the image we want to compare against.
//
// We make sure to turn the image into RGB8 as FLIP doesn't deal with alpha.
let ref_image_data = image::open("../etc/tree-ref.png").unwrap().into_rgb8();
let ref_image = nv_flip::FlipImageRgb8::with_data(
    ref_image_data.width(),
    ref_image_data.height(),
    &ref_image_data
);

// We then load the "test image". This is the image we want to compare to the reference.
let test_image_data = image::open("../etc/tree-test.png").unwrap().into_rgb8();
let test_image = nv_flip::FlipImageRgb8::with_data(
    test_image_data.width(),
    test_image_data.height(),
    &test_image_data
);

// We now run the comparison. This will produce a "error map" that that is the per-pixel
// visual difference between the two images between 0 and 1.
//
// The last parameter is the number of pixels per degree of visual angle. This is used
// to determine the size of imperfections that can be seen. See the `pixels_per_degree`
// for more information. By default this value is 67.0.
let error_map = nv_flip::flip(ref_image, test_image, nv_flip::DEFAULT_PIXELS_PER_DEGREE);

// We can now visualize the error map using a LUT that maps the error value to a color.
let visualized = error_map.apply_color_lut(&nv_flip::magma_lut());

// Finally we can the final image into an `image` crate image and save it.
let image = image::RgbImage::from_raw(
    visualized.width(),
    visualized.height(),
    visualized.to_vec()
).unwrap();

// We can get statistics about the error map by using their "Pool" type,
// which is essentially a weighted histogram.
let mut pool = nv_flip::FlipPool::from_image(&error_map);

// These are the same statistics shown by the command line.
//
// The paper's writers recommend that, if you are to use a single number to
// represent the error, they recommend the mean.
println!("Mean: {}", pool.mean());
println!("Weighted median: {}", pool.get_percentile(0.5, true));
println!("1st weighted quartile: {}", pool.get_percentile(0.25, true));
println!("3rd weighted quartile: {}", pool.get_percentile(0.75, true));
println!("Min: {}", pool.min_value());
println!("Max: {}", pool.max_value());

此示例的结果如下

参考 ⠀⠀测试⠀⠀ ⠀结果⠀⠀
comp comp comp

许可证

绑定和 rust 互操作代码受 MIT、Apache-2.0 和 ZLib 许可的约束。

ꟻLIP 库本身受 BSD-3-Clause 许可的约束。

使用的示例图像受 Unsplash 许可 的约束。

许可证:MIT OR Apache-2.0 OR Zlib

依赖项