image-rs / jpeg-decoder

JPEG decoder written in Rust
Apache License 2.0
149 stars 87 forks source link

Lossless JPEG #191

Closed vsaase closed 2 years ago

vsaase commented 3 years ago

Hi,

in the medical community the Lossless JPEG format (SOF type 0xc3, not JPEG-LS or JPEG2000) is very popular due to the DICOM standard. It is used for graytone images, 16 bit or 12 bit most of the time.

Some links:

Implementations of JPEG Lossless (SOF type 0xc3):

Is anyone aware of Rust implementations? Is there maybe a quick way to do it using existing code of this library? Probably the main difficulty would be to support 16 bit?

vsaase commented 3 years ago

I now implemented Lossless decoding in my fork: https://github.com/vsaase/jpeg-decoder/tree/lossless

This is at the moment however a breaking change, as the decode function returns u16 instead of u8 and also internally data is now u16. We could use generics to support both.

fintelia commented 3 years ago

Other image-rs crates use &[u8] slices to store pixel data, even when the pixels themselves are u16's or f32's. Think that could work here?

vsaase commented 3 years ago

Ok, I changed it so that for 16bit images decode now returns big endian u8 bytes, like the png crate.

fintelia commented 3 years ago

If possible, native endian would be preferable to big endian. In the main image crate we actually end up having to swap the byte order for PNG's

vsaase commented 3 years ago

I also prefer native endian, changed it. I don't see the JPEG standard making a statement to that.

Shnatsel commented 2 years ago

Lossless JPEG has been implemented in #193; I believe this issue can be closed.