Skip to content

Commit fcdb5f0

Browse files
authored
Merge pull request #272 from Enet4/imp/lossless-bitdepth
Admit more precision values in JPEG Lossless
2 parents 4d38958 + 1e5b891 commit fcdb5f0

30 files changed

+27
-8
lines changed

benches/decoding_benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main() {
3535
}));
3636

3737
c.bench_function("decode a 3072x2048 RGB Lossless JPEG", |b| b.iter(|| {
38-
read_image(include_bytes!("../tests/reftest/images/lossless/jpeg_lossless_sel1-rgb.jpg"))
38+
read_image(include_bytes!("../tests/reftest/images/lossless/1/jpeg_lossless_sel1-rgb.jpg"))
3939
}));
4040
c.final_summary();
4141
}

src/decoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ impl<R: Read> Decoder<R> {
173173
Some(ref frame) => {
174174
let pixel_format = match frame.components.len() {
175175
1 => match frame.precision {
176-
8 => PixelFormat::L8,
177-
16 => PixelFormat::L16,
176+
2..=8 => PixelFormat::L8,
177+
9..=16 => PixelFormat::L16,
178178
_ => panic!(),
179179
},
180180
3 => PixelFormat::RGB24,
@@ -360,7 +360,7 @@ impl<R: Read> Decoder<R> {
360360
frame.precision,
361361
)));
362362
}
363-
if frame.precision != 8 && frame.precision != 16 {
363+
if !(2..=16).contains(&frame.precision) {
364364
return Err(Error::Unsupported(UnsupportedFeature::SamplePrecision(
365365
frame.precision,
366366
)));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# JPEG Lossless data set 1
2+
3+
The files starting with jpeg_lossless were taken from <https://github.com/rii-mango/JPEGLosslessDecoderJS>.
4+
The image data bytes were extracted from the DICOM files.
5+
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>.
150 KB
Loading
162 KB
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# JPEG Lossless data set 2
2+
3+
The JPEG losssless files in this data set
4+
were collected from the DICOM-WG04 compilation of public DICOM files in
5+
<ftp://medical.nema.org/medical/dicom/DataSets/WG04> (revision 2004/08/26),
6+
extracting the JPEG data from the files' pixel data.
7+
8+
The ground truth was collected from the respective reference (uncompressed) files
9+
and converted to 16-bit PNG files.
10+
11+
## Description
12+
13+
- **MR4**: 512x512, 12 bit precision, non-hierarchical, selection value 1
14+
- JPEG extracted from DICOM file `JPLL/MR4_JPLL`
15+
- Ground truth converted from DICOM file `REF/MR4_UNC`
16+
- **XA1**: 1024x1024, 10 bit precision, non-hierarchical, selection value 1
17+
- JPEG extracted from DICOM file `JPLL/XA1_JPLL`
18+
- Ground truth converted from DICOM file `REF/XA1_UNC`
483 KB
Loading
515 KB
Loading

tests/reftest/images/lossless/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)