-
Notifications
You must be signed in to change notification settings - Fork 146
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
Allow callers to pass in output buffers #685
Comments
Have you seen the As for processing on data from external sources I think you should be able to construct an |
Those are in place though (at least the ones I found, like |
See #622 where I had similar thoughts. |
What do you think about something like this? You would only have to implement |
I think that could work, but some downsides I can think of might be:
|
On the other hand standardizing image ops into traits does make it possible to do more advanced usage in generic scenarios such as taking any image ops as an input itself like higher kinded programming does with functions: fn apply_op_twice<O>(op : O, image: Image) where O: ImageOp {
Op.call(image);
Op.call(image);
} Maybe we could even do both methods and write a proc macro which would generate our current non-trait free-standing functions which internally then construct the op struct and then call the structs op impl. This way we get the best of both worlds and give the users the flexibility to choose which method they prefer. At the cost of increased beginner difficulty. |
Okay, so since there is some interest I'll try and come up with some possible design ideas that can take into account some of the more complex cases and the points you mentioned.
I think you'd just put the docs for how a filter works on the struct for it, so they appear at the very top and not in the trait docs.
More than ergonomics actually, since |
Ok, I have thought about some of these points and hope to flesh them out in a master's thesis, so I'll have some better insights after that hopefully. The Curious what others here think, because I think basically reimplementing OpenCV in the age of projects like pytorch is a little bit of a wasted effort. Declarative approaches where operations are completely abstracted away from the actual representation in memory such that optimizations like loop blocking, kernel fusion can be applied over the whole pipeline are the future IMO. I definitely understand if this isn't meant to be a research project tho so excuse my ramblings in that case :D |
I'm finding myself wanting to scale/blur/whatever images into an
ndarray
Array3
. Butimageproc
functions all allocate their own output, which is suboptimal in many cases, for example when:I'm not sure adding
do_thing_into
functions for every function in the library is the best way to do this and using inout parameters is cumbersome compared to the current default, so some more generic way to make operations (somewhat) agnostic to where they shove their output might be appropriate.I'm willing to put some time into this, but given that this would break literally every API in the crate I wanted to ask for some opinions before maybe investigating how this could be done.
The text was updated successfully, but these errors were encountered: