-
Notifications
You must be signed in to change notification settings - Fork 4
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
Ability to use a image::ImageBuffer directly? #1
Comments
Thanks for your comment and I'm glad it worked for your project 😀. It's an interesting idea but I think it would add some problems, complexity and you will not gain a lot. let mut bits = vec![vec![0i8; width]; height];
for p in img.pixels() {
if p.2 == image::Luma([0]) {
bits[p.1 as usize][p.0 as usize] = 1;
}
} The way it works and to directly use the buffer, it would need to be expanded to add a border and eventually converted to 8 bits. |
Thanks. Yes my code looks almost like that :-) I wanted to avoid the double memory usage, and needless copies. Ah looking at your code now, I see you also do a full copy, to add the border around it. So I guess, accepting a ImageBuffer would allow me to avoid one full copy, but you could easily still do that internally. Either way, no worries if you don't think this is worth adding. I just figured must folks would be doing the processing on images. |
The library do a little bit more than a simple copy, it adds a border and changes the 0 to -1 to make the rest easier to process. How would you process a 1bit image knowing that you need values other than 0 or 1 ? |
Well rust vectors do have .get() which allow out of bounds and return Optional. So something like |
Thanks, I'll have a look and try that. |
get_pixel() can't return Optional and just panic.
So, I've added a function single_l8_to_paths() and avoided the panics differently but it's still not optimized: It needs the feature "image" so don't forget to change your Cargo.toml:
Please try this and don't hesitate to report some issues. |
Firstly thanks for this library. It worked great for a project I'm working on.
One feature request. I have a image::ImageBuffer and I'd like to pass it directly to
bits_to_paths
, instead I have to copy it into aVec::<Vec<i8>>
. For example:Thanks
The text was updated successfully, but these errors were encountered: