Implement less abstracted nearest filtering.
Add some tests that try to compare image's Nearest with my implementation. According the PSNR they're very different, but to a human the look the same.
This commit is contained in:
@@ -2,12 +2,13 @@ use criterion::BenchmarkId;
|
||||
use criterion::Throughput;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
|
||||
use image::imageops::FilterType;
|
||||
use image::imageops;
|
||||
use image::GenericImageView;
|
||||
|
||||
use photosync::library::load_image;
|
||||
use photosync::library::resize;
|
||||
use photosync::library::save_to_jpeg_bytes;
|
||||
use photosync::library::FilterType;
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
const TEST_IMAGE_PATH: &'static str = "testdata/image.jpg";
|
||||
@@ -28,9 +29,10 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
{
|
||||
let (w, h) = size;
|
||||
for filter in [
|
||||
FilterType::Builtin(imageops::Nearest),
|
||||
FilterType::Builtin(imageops::CatmullRom),
|
||||
FilterType::Builtin(imageops::Lanczos3),
|
||||
FilterType::Nearest,
|
||||
FilterType::CatmullRom,
|
||||
FilterType::Lanczos3,
|
||||
]
|
||||
.iter()
|
||||
{
|
||||
@@ -62,7 +64,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
),
|
||||
size,
|
||||
|b, size| {
|
||||
let small_img = resize(&img, *size, FilterType::Lanczos3);
|
||||
let small_img = resize(&img, *size, FilterType::Builtin(imageops::Lanczos3));
|
||||
b.iter(|| black_box(save_to_jpeg_bytes(&small_img)))
|
||||
},
|
||||
);
|
||||
@@ -80,7 +82,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
|b, size| {
|
||||
b.iter(|| {
|
||||
let img = load_image(TEST_IMAGE_PATH).expect("failed to load test image");
|
||||
let small_img = resize(&img, *size, FilterType::Lanczos3);
|
||||
let small_img = resize(&img, *size, FilterType::Builtin(imageops::Lanczos3));
|
||||
black_box(save_to_jpeg_bytes(&small_img))
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user