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

To image? #9

Open
maufl opened this issue Jan 2, 2022 · 2 comments
Open

To image? #9

maufl opened this issue Jan 2, 2022 · 2 comments

Comments

@maufl
Copy link

maufl commented Jan 2, 2022

I tried to figure out how to use this crate to convert a Array2 to and grayscale image, and I found the ToImageLuma trait. It seems like this trait is not implemented by anything, right? So this crate does not provide conversions to images?

@vadixidav
Copy link
Member

@maufl It does not directly support it, but a trick you can do until someone implements it is that you can use the following:

https://docs.rs/nshare/0.8.0/nshare/trait.MutNdarray2.html#impl-MutNdarray2-for-%26%27a%20mut%20ImageBuffer%3CLuma%3CA%3E%2C%20Container%3E

This implementation allows you to take a luma image buffer and get an ndarray 2d mutable slice over it. You can then easily copy the data from one ndarray to the other using assign: https://docs.rs/ndarray/0.15.4/ndarray/struct.ArrayBase.html#method.assign

Contributions are absolutely welcome as well if you would like to implement it.

@maufl
Copy link
Author

maufl commented Jan 2, 2022

Thanks for the quick response! I can give it a try, I'm not yet feeling to comfortable with ndarray though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants