kornia / kornia-rs

Low-level Computer Vision library in Rust
https://docs.rs/kornia
Apache License 2.0
176 stars 16 forks source link

Support reading images other thant RGB #149

Open edgarriba opened 1 week ago

edgarriba commented 1 week ago

Expand kornia_io::functional::read_image_any to read / decode images in more formats such as u16

reference: https://github.com/kornia/kornia-rs/blob/main/crates/kornia-io/src/functional.rs#L104

NOTE: Take especial care when constructing the Image to avoid copies: https://github.com/kornia/kornia-rs/blob/main/crates/kornia-io/src/functional.rs#L130

edgarriba commented 1 week ago

@emilmgeorge this is another use case for allowing Tensor / Image to be created with zero copy overhead

emilmgeorge commented 6 days ago

NOTE: Take especial care when constructing the Image to avoid copies: https://github.com/kornia/kornia-rs/blob/main/crates/kornia-io/src/functional.rs#L130

https://github.com/kornia/kornia-rs/blob/a4b5fd4b6084a48c3be5e3f97b7d568f48d0f53a/crates/kornia-io/src/functional.rs#L130

Here img.into_rgb8().into_vec() could be used instead:

edgarriba commented 5 days ago

@emilmgeorge awesome, I'll give it a shot. Also we can start supporting to return a generic C. What's your opinion to encode the PixelFormat too in the Image struct ? I like the current definition because is very flexible to have more generic imgproc operators, but at the same time i kind of miss the color space semantics.

edgarriba commented 5 days ago

a small pov here https://github.com/kornia/kornia-rs/pull/154 feel free to comment

emilmgeorge commented 5 days ago

Your implementation in #154 looks good. 👍🏼 I do not have any better ideas.