JuliaImages / ImageDistances.jl

Distances between N-dimensional images
https://github.com/JuliaImages/Images.jl
Other
15 stars 8 forks source link

redesign the type hierarchy #7

Closed johnnychen94 closed 5 years ago

johnnychen94 commented 5 years ago

Currently

# in Distances.jl
abstract type PreMetric end
abstract type SemiMetric <: PreMetric end
abstract type Metric <: SemiMetric end

# in ImageDistances.jl
abstract type ImagePreMetric end
abstract type ImageSemiMetric <: ImagePreMetric end
abstract type ImageMetric <: ImageSemiMetric end

Types in Distances and ImageDistances are independent.

If we want to use codes from Distances package, I think an easier path is to define

abstract type ImagePreMetric <: Distances.PreMetric end
abstract type ImageSemiMetric <: Distances.SemiMetric end
abstract type ImageMetric <: Distances.Metric end

so that we only need to handle two special types: Normed and Colorant

juliohm commented 5 years ago

Lovely! I think it makes sense. Thanks for the insights. Could you please submit a PR for this change? I'd happy to review and merge.

johnnychen94 commented 5 years ago

I'm willing to, perhaps one or two weeks later. In the meantime, I might need your help since I don't quite understand how Hausdauff works ( If I need to change the code).

The PR https://github.com/JuliaImages/ImageDistances.jl/pull/6 will be paused until this's done.

juliohm commented 5 years ago

Sure, I'd be happy to help. Please let me know how the implementation of Hausdorff conflicts with the proposed change, and we will work together to make it work.

Thanks for the time again. I am looking forward to it.

juliohm commented 5 years ago

Just a follow up on this issue. The Hausdorff distance is specific to images in the sense that it is a clever combination of other distances defined in Distances.jl. We consider a black and white image as a point cloud and then perform calculations with traditional distances on this point cloud.

This distance cannot be implemented in Distances.jl because it is too specific for the context of images, but we can still incorporate your proposal for normal distances like Euclidean, etc that operate pixelwise.

johnnychen94 commented 5 years ago

After some investigation, I can't see the advantages of introducing another ImagePreMetric type. Directly implement image-specific functions based on Distances is enough.

related PR: https://github.com/JuliaStats/Distances.jl/pull/128