image-rs / image

Encoding and decoding images in Rust
Apache License 2.0
4.9k stars 605 forks source link

Support for single-channel f32 grayscale images? #1940

Open stephanemagnenat opened 1 year ago

stephanemagnenat commented 1 year ago

It is common in computer vision to have grayscale images with a single f32 channel, for example the Akaze feature detector in OpenCV uses that. Formats such as OpenEXR and related exr library in Rust support that.

However, currently the ColorType doesn't support it. This prevents a simple use of image to save images in this format. I believe that it would be helpful to add support for that (that would be a L32F). Is there an interest or plan for such addition?

fintelia commented 1 year ago

At some point I'd like to enable saving images with formats beyond those in ColorType which would resolve this without needing to add more core color types to the library. See https://github.com/image-rs/image/issues/1849#issuecomment-1423631926

A lot of the hesitance comes from wanting to keep the list of DynamicImage variants in sync with the values of ColorType

stephanemagnenat commented 1 year ago

I see! Yes, that makes sense, from my point of view the goal is not to have an over-fat DynamicImage but to have convenient features on ImageBuffer. Currently, saving a ImageBuffer<Luma<f32>, Vec<f32>> to an EXR file fails, and that is what I would expect to succeed.

Should I rename this issue or create a new one to focus on saving/loading of such?