-
Notifications
You must be signed in to change notification settings - Fork 98
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
Is there a way for the user to define a metric by themself? #95
Comments
Sure, all metrics in the package are written by someone, they are not magically built in Julia. So you can closely follow the examples written here. Generally, you will need to first create a metric type
You will then need to define an instance of
You then have automatically generic |
Hello Daniel,
Thank you kindly for your reply.
Actually what I am asking is that whether an additional metric can be added without touching the original files of the package, as I want to later distribute my package as well. Is there an interface to do that?
Thanks,
Junteng
…Sent from my iPhone
On Jun 20, 2018, at 12:36 PM, Daniel Karrasch <[email protected]<mailto:[email protected]>> wrote:
Sure, all metrics in the package are written by someone, they are not magically built in Julia. So you can closely follow the examples written here. Generally, you will need to first create a metric type
struct MyMetric <: Metric end
You will then need to define an instance of evaluate:
function evaluate(dist::MyMetric,a::AbstractArray,b::AbstractArray)
# how to compute dist(a,b)
end
You then have automatically generic pairwise and colwise functions, which you can specifically optimize if needed, analogously to pairwise(::Euclidean,A,B) etc. It is probably easiest if you start with the whole block of code related to one specific metric that is somewhat close to your required structure, i.e., including convenience functions like, e.g., euclidean(a,b), and modify it according to your own needs. Hope this helps.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#95 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALIs3kf6RIIdx-VZiqNHHQbaiftFULRYks5t-nokgaJpZM4UvlxW>.
|
That's possible. You first |
There is one more detail: you will need to explicitly import those methods from |
Thank you for your information! |
I am trying to do the same right now, but it appears to be very difficult to do properly. In addition to the various
which I believe is needed in the After doing this, I run into the problem that I believe this is related to the discussion in #150. I would be grateful about advice on how to define "proper" custom metric in the most recent version, that takes advantage of the existing and theoretically generic code. |
If you're interested, https://github.com/JuliaImages/ImageDistances.jl/blob/10ebabafc534d0fc7046960558882b7606153adb/src/metrics.jl#L106-L131 is a live demo of defining new "metrics" for image inputs outside of |
Lines 212 to 214 in 8d6e093
Your example above is similar to |
No description provided.
The text was updated successfully, but these errors were encountered: