Skip to content

Commit

Permalink
test: improve i2syntax tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AzHicham committed Nov 13, 2023
1 parent c1a46dc commit 05b5f6d
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/test_pixel_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn test_containers() {

#[rstest]
fn test_container_version() {
let slide = PhilipsEngine::new();
let slide = PhilipsEngine::default();
assert_eq!(slide.container_version("ficom").unwrap(), "100.5");
}

Expand Down
104 changes: 103 additions & 1 deletion tests/test_subimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod fixture;

#[cfg(feature = "image")]
use {
fixture::sample,
fixture::{sample, sample_i2syntax},
philips_isyntax_rs::{ContainerName, ImageType, PhilipsEngine},
rstest::rstest,
std::path::Path,
Expand Down Expand Up @@ -128,3 +128,105 @@ fn test_sub_image_label(#[case] filename: &Path) {
)
.unwrap();
}

#[rstest]
#[case(sample_i2syntax())]
#[cfg(feature = "image")]
fn test_i2syntax_sub_image_slide(#[case] filename: &Path) {
let engine = PhilipsEngine::new();
let facade = engine
.facade(filename, &ContainerName::CachingFicom)
.unwrap();
let image = facade.image(&ImageType::WSI).unwrap();

assert_eq!(image.pixel_transform().unwrap(), "legall53");
assert_eq!(image.quality_preset().unwrap(), "Q2");
assert_eq!(image.quality().unwrap(), 18446744073709551615);
assert_eq!(image.compressor().unwrap(), "hulsken2");
assert_eq!(image.colorspace_transform().unwrap(), "RGB2YCoCg");
assert_eq!(image.num_tiles().unwrap(), 2097168);
assert!(image.icc_profile().is_ok()); // too long to display
assert_eq!(
image.icc_matrix().unwrap(),
[
1.7378870276206972, -0.3340537894621137, 0.02305579175279321, -0.28660139078112445, 1.4693326858187172, -0.5411745946267302, -0.3561981843724411, -0.04204419797506245, 1.6160681688222087
]
);
assert_eq!(image.lossy_image_compression().unwrap(), "01");
assert_eq!(image.lossy_image_compression_ratio().unwrap(), 15.0);
assert_eq!(image.color_linearity().unwrap(), "linear");
// image_data not available for slide image
assert_eq!(image.image_data().unwrap().len(), 0);
}

#[rstest]
#[case(sample_i2syntax())]
#[cfg(feature = "image")]
fn test_i2syntax_sub_image_macro(#[case] filename: &Path) {
let engine = PhilipsEngine::new();
let facade = engine
.facade(filename, &ContainerName::CachingFicom)
.unwrap();
let image = facade.image(&ImageType::MacroImage).unwrap();

// Some function are only available with ImageType::WSI
assert!(image.pixel_transform().is_err());
assert!(image.quality_preset().is_err());
assert!(image.quality().is_err());
assert!(image.compressor().is_err());
assert!(image.colorspace_transform().is_err());
assert!(image.num_tiles().is_err());
assert!(image.color_linearity().is_err());
assert!(image.icc_profile().is_ok()); // too long to display
assert!(
image.icc_matrix().is_err()
);
assert_eq!(image.lossy_image_compression().unwrap(), "");
assert!(image.lossy_image_compression_ratio().is_err());
assert_eq!(image.image_data().unwrap().len(), 1209706);

let macro_image = image.get_image().unwrap();
image::save_buffer(
Path::new("macro_image.jpeg"),
macro_image.as_bytes(),
macro_image.width(),
macro_image.height(),
macro_image.color(),
)
.unwrap();
}

#[rstest]
#[case(sample_i2syntax())]
#[cfg(feature = "image")]
fn test_i2syntax_sub_image_label(#[case] filename: &Path) {
let engine = PhilipsEngine::new();
let facade = engine
.facade(filename, &ContainerName::CachingFicom)
.unwrap();
let image = facade.image(&ImageType::LabelImage).unwrap();

// Some function are only available with ImageType::slide
assert!(image.pixel_transform().is_err());
assert!(image.quality_preset().is_err());
assert!(image.quality().is_err());
assert!(image.compressor().is_err());
assert!(image.colorspace_transform().is_err());
assert!(image.num_tiles().is_err());
assert!(image.color_linearity().is_err());
assert!(image.icc_matrix().is_err());
assert!(image.icc_profile().is_ok()); // too long to display
assert_eq!(image.lossy_image_compression().unwrap(), "");
assert!(image.lossy_image_compression_ratio().is_err());
assert_eq!(image.image_data().unwrap().len(), 470591);

let label_image = image.get_image().unwrap();
image::save_buffer(
Path::new("label_image.jpeg"),
label_image.as_bytes(),
label_image.width(),
label_image.height(),
label_image.color(),
)
.unwrap();
}

1 comment on commit 05b5f6d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

philips-isyntax-rs Benchmark

Benchmark suite Current: 05b5f6d Previous: c1a46dc Ratio
philips_i2syntax_read_region_256_lvl_0 1376101 ns/iter (± 194769) 1352447 ns/iter (± 509907) 1.02
philips_i2syntax_read_region_256_lvl_1 1164764 ns/iter (± 65624) 1292168 ns/iter (± 297958) 0.90
philips_i2syntax_read_region_512_lvl_0 1564761 ns/iter (± 225872) 1549696 ns/iter (± 475843) 1.01
philips_i2syntax_read_region_512_lvl_1 7479935 ns/iter (± 552847) 7336469 ns/iter (± 392230) 1.02
philips_read_region_256_lvl_0 518950 ns/iter (± 44642) 496200 ns/iter (± 39314) 1.05
philips_read_region_256_lvl_1 1264704 ns/iter (± 45654) 1227744 ns/iter (± 49968) 1.03
philips_read_region_512_lvl_0 3630509 ns/iter (± 170518) 3530219 ns/iter (± 101215) 1.03
philips_read_region_512_lvl_1 2804305 ns/iter (± 149440) 2728007 ns/iter (± 81375) 1.03

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.