Open edgarriba opened 1 week ago
@emilmgeorge this is another use case for allowing Tensor
/ Image
to be created with zero copy overhead
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
Here img.into_rgb8().into_vec()
could be used instead:
into_rgb8()
creates a copy only if img
is not already in RGB8 format.into_vec()
consumes the image and gives us the inner vector without copy. to_vec
, on the other hand, seems to point to slice::to_vec
(according to rust-analyzer) which copies.@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.
a small pov here https://github.com/kornia/kornia-rs/pull/154 feel free to comment
Your implementation in #154 looks good. 👍🏼 I do not have any better ideas.
Expand
kornia_io::functional::read_image_any
to read / decode images in more formats such as u16reference: 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