Closed johnnychen94 closed 3 years ago
Is the main advantage here more concise code?
That's one and the main advantage.
To support N-D array, in JuliaImages we take pixels as array elements. This is a great design, however, this would cause confusion when someone directly calls a function without channelview it.
For example, for RGB images, Minkowski{2}
distance isn't equivalent to Euclidean
distance. https://github.com/JuliaImages/ImageDistances.jl/issues/16#issuecomment-519754529
Introducing this macro would make this situation easy to explain and easy to avoid. "Okay, you forgot to use it channelwisely"
If both channelwised version and non-channelwised version can be called in one line; it's much easier to spell 😃 .
Hey @johnnychen94 I am planning on working on this if it hasn't been added. I am relatively new to Julia, any tips on getting started? Thanks!
I believe some understanding of the color systems of JuliaImages, and the metaprogramming would be sufficient for you to start with. Actually, there's a WIP PR for this https://github.com/JuliaImages/ImageCore.jl/pull/105 that you can use as a reference. Part of the reason I didn't continue it is because I wasn't very familiar with macros and I am still not. :cry:
Speaking of performance, this @channelview
is probably not a good option (see the comments
https://github.com/JuliaImages/ImageCore.jl/pull/105#issuecomment-569506758) , but I should say we need benchmarks to say so.
Abusing channelview
has the tendency to goes against our best practice and thus hurt the performance so now I realize that we shouldn't provide this.
I'm closing this in favor of the docs https://github.com/JuliaImages/juliaimages.github.io/issues/206 and alternative https://github.com/JuliaImages/ImageCore.jl/issues/170
I don't have a specific implementation in mind, but the following usage is really common:
If we could replace this as something like...
Similarly, replace
as
This is a very draft idea.