Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reading images other thant RGB #149

Open
edgarriba opened this issue Sep 26, 2024 · 5 comments
Open

Support reading images other thant RGB #149

edgarriba opened this issue Sep 26, 2024 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@edgarriba
Copy link
Member

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 edgarriba added enhancement New feature or request help wanted Extra attention is needed labels Sep 26, 2024
@edgarriba
Copy link
Member Author

edgarriba commented Sep 26, 2024

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

@emilmgeorge
Copy link
Contributor

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

img.to_rgb8().to_vec(),

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.

@edgarriba
Copy link
Member Author

@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
Copy link
Member Author

a small pov here #154 feel free to comment

@emilmgeorge
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants