diff --git a/benches/decoding_benchmark.rs b/benches/decoding_benchmark.rs index fb8282de..544e9a29 100644 --- a/benches/decoding_benchmark.rs +++ b/benches/decoding_benchmark.rs @@ -35,7 +35,7 @@ fn main() { })); c.bench_function("decode a 3072x2048 RGB Lossless JPEG", |b| b.iter(|| { - read_image(include_bytes!("../tests/reftest/images/lossless/jpeg_lossless_sel1-rgb.jpg")) + read_image(include_bytes!("../tests/reftest/images/lossless/1/jpeg_lossless_sel1-rgb.jpg")) })); c.final_summary(); } \ No newline at end of file diff --git a/src/decoder.rs b/src/decoder.rs index dab62546..b8eb5311 100644 --- a/src/decoder.rs +++ b/src/decoder.rs @@ -173,8 +173,8 @@ impl Decoder { Some(ref frame) => { let pixel_format = match frame.components.len() { 1 => match frame.precision { - 8 => PixelFormat::L8, - 16 => PixelFormat::L16, + 2..=8 => PixelFormat::L8, + 9..=16 => PixelFormat::L16, _ => panic!(), }, 3 => PixelFormat::RGB24, @@ -360,7 +360,7 @@ impl Decoder { frame.precision, ))); } - if frame.precision != 8 && frame.precision != 16 { + if !(2..=16).contains(&frame.precision) { return Err(Error::Unsupported(UnsupportedFeature::SamplePrecision( frame.precision, ))); diff --git a/tests/reftest/images/lossless/LICENSE b/tests/reftest/images/lossless/1/LICENSE similarity index 100% rename from tests/reftest/images/lossless/LICENSE rename to tests/reftest/images/lossless/1/LICENSE diff --git a/tests/reftest/images/lossless/1/README.md b/tests/reftest/images/lossless/1/README.md new file mode 100644 index 00000000..93af750c --- /dev/null +++ b/tests/reftest/images/lossless/1/README.md @@ -0,0 +1,5 @@ +# JPEG Lossless data set 1 + +The files starting with jpeg_lossless were taken from . +The image data bytes were extracted from the DICOM files. +The reference PNG files were created with the IJG library as distributed in the GDCM toolkit . diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel1-8bit.jpg b/tests/reftest/images/lossless/1/jpeg_lossless_sel1-8bit.jpg similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel1-8bit.jpg rename to tests/reftest/images/lossless/1/jpeg_lossless_sel1-8bit.jpg diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel1-8bit.png b/tests/reftest/images/lossless/1/jpeg_lossless_sel1-8bit.png similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel1-8bit.png rename to tests/reftest/images/lossless/1/jpeg_lossless_sel1-8bit.png diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel1-rgb.jpg b/tests/reftest/images/lossless/1/jpeg_lossless_sel1-rgb.jpg similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel1-rgb.jpg rename to tests/reftest/images/lossless/1/jpeg_lossless_sel1-rgb.jpg diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel1-rgb.png b/tests/reftest/images/lossless/1/jpeg_lossless_sel1-rgb.png similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel1-rgb.png rename to tests/reftest/images/lossless/1/jpeg_lossless_sel1-rgb.png diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel1.jpg b/tests/reftest/images/lossless/1/jpeg_lossless_sel1.jpg similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel1.jpg rename to tests/reftest/images/lossless/1/jpeg_lossless_sel1.jpg diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel1.png b/tests/reftest/images/lossless/1/jpeg_lossless_sel1.png similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel1.png rename to tests/reftest/images/lossless/1/jpeg_lossless_sel1.png diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel2.jpg b/tests/reftest/images/lossless/1/jpeg_lossless_sel2.jpg similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel2.jpg rename to tests/reftest/images/lossless/1/jpeg_lossless_sel2.jpg diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel2.png b/tests/reftest/images/lossless/1/jpeg_lossless_sel2.png similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel2.png rename to tests/reftest/images/lossless/1/jpeg_lossless_sel2.png diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel3.jpg b/tests/reftest/images/lossless/1/jpeg_lossless_sel3.jpg similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel3.jpg rename to tests/reftest/images/lossless/1/jpeg_lossless_sel3.jpg diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel3.png b/tests/reftest/images/lossless/1/jpeg_lossless_sel3.png similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel3.png rename to tests/reftest/images/lossless/1/jpeg_lossless_sel3.png diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel4.jpg b/tests/reftest/images/lossless/1/jpeg_lossless_sel4.jpg similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel4.jpg rename to tests/reftest/images/lossless/1/jpeg_lossless_sel4.jpg diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel4.png b/tests/reftest/images/lossless/1/jpeg_lossless_sel4.png similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel4.png rename to tests/reftest/images/lossless/1/jpeg_lossless_sel4.png diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel5.jpg b/tests/reftest/images/lossless/1/jpeg_lossless_sel5.jpg similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel5.jpg rename to tests/reftest/images/lossless/1/jpeg_lossless_sel5.jpg diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel5.png b/tests/reftest/images/lossless/1/jpeg_lossless_sel5.png similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel5.png rename to tests/reftest/images/lossless/1/jpeg_lossless_sel5.png diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel6.jpg b/tests/reftest/images/lossless/1/jpeg_lossless_sel6.jpg similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel6.jpg rename to tests/reftest/images/lossless/1/jpeg_lossless_sel6.jpg diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel6.png b/tests/reftest/images/lossless/1/jpeg_lossless_sel6.png similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel6.png rename to tests/reftest/images/lossless/1/jpeg_lossless_sel6.png diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel7.jpg b/tests/reftest/images/lossless/1/jpeg_lossless_sel7.jpg similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel7.jpg rename to tests/reftest/images/lossless/1/jpeg_lossless_sel7.jpg diff --git a/tests/reftest/images/lossless/jpeg_lossless_sel7.png b/tests/reftest/images/lossless/1/jpeg_lossless_sel7.png similarity index 100% rename from tests/reftest/images/lossless/jpeg_lossless_sel7.png rename to tests/reftest/images/lossless/1/jpeg_lossless_sel7.png diff --git a/tests/reftest/images/lossless/lossless16bit.jpg b/tests/reftest/images/lossless/1/lossless16bit.jpg similarity index 100% rename from tests/reftest/images/lossless/lossless16bit.jpg rename to tests/reftest/images/lossless/1/lossless16bit.jpg diff --git a/tests/reftest/images/lossless/lossless16bit.png b/tests/reftest/images/lossless/1/lossless16bit.png similarity index 100% rename from tests/reftest/images/lossless/lossless16bit.png rename to tests/reftest/images/lossless/1/lossless16bit.png diff --git a/tests/reftest/images/lossless/2/MR4.jpg b/tests/reftest/images/lossless/2/MR4.jpg new file mode 100644 index 00000000..842b6a0f Binary files /dev/null and b/tests/reftest/images/lossless/2/MR4.jpg differ diff --git a/tests/reftest/images/lossless/2/MR4.png b/tests/reftest/images/lossless/2/MR4.png new file mode 100644 index 00000000..bffb3198 Binary files /dev/null and b/tests/reftest/images/lossless/2/MR4.png differ diff --git a/tests/reftest/images/lossless/2/README.md b/tests/reftest/images/lossless/2/README.md new file mode 100644 index 00000000..39cde161 --- /dev/null +++ b/tests/reftest/images/lossless/2/README.md @@ -0,0 +1,18 @@ +# JPEG Lossless data set 2 + +The JPEG losssless files in this data set +were collected from the DICOM-WG04 compilation of public DICOM files in + (revision 2004/08/26), +extracting the JPEG data from the files' pixel data. + +The ground truth was collected from the respective reference (uncompressed) files +and converted to 16-bit PNG files. + +## Description + +- **MR4**: 512x512, 12 bit precision, non-hierarchical, selection value 1 + - JPEG extracted from DICOM file `JPLL/MR4_JPLL` + - Ground truth converted from DICOM file `REF/MR4_UNC` +- **XA1**: 1024x1024, 10 bit precision, non-hierarchical, selection value 1 + - JPEG extracted from DICOM file `JPLL/XA1_JPLL` + - Ground truth converted from DICOM file `REF/XA1_UNC` diff --git a/tests/reftest/images/lossless/2/XA1.jpg b/tests/reftest/images/lossless/2/XA1.jpg new file mode 100644 index 00000000..2d3ad3e4 Binary files /dev/null and b/tests/reftest/images/lossless/2/XA1.jpg differ diff --git a/tests/reftest/images/lossless/2/XA1.png b/tests/reftest/images/lossless/2/XA1.png new file mode 100644 index 00000000..8fbcb5b9 Binary files /dev/null and b/tests/reftest/images/lossless/2/XA1.png differ diff --git a/tests/reftest/images/lossless/README.md b/tests/reftest/images/lossless/README.md deleted file mode 100644 index e688135c..00000000 --- a/tests/reftest/images/lossless/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# lossless -The files starting with jpeg_lossless were taken from https://github.com/rii-mango/JPEGLosslessDecoderJS -The image data bytes were extracted from the DICOM files. -The reference PNG files were created with the IJG library as distributed in the GDCM toolkit https://github.com/malaterre/GDCM/tree/master/Utilities/gdcmjpeg. \ No newline at end of file