Code Monkey home page Code Monkey logo

py-hausdorff's Introduction

py-hausdorff

Fast computation of Hausdorff distance in Python/Cython.

This code implements the algorithm presented in An Efficient Algorithm for Calculating the Exact Hausdorff Distance (DOI: 10.1109/TPAMI.2015.2408351) by Aziz and Hanbury.

To install the package I provide you a setup.py file. You must run:

python setup.py install

The main functions is:

hausdorff(np.ndarray[:,:] X, np.ndarray[:,:] Y)

Which computes the Hausdorff distance between the rows of X and Y using the Euclidean distance as metric. It receives the optional argument distance (string), which is the distance function used to compute the distance between the rows of X and Y. It could be any of the following: manhattan, euclidean (default), chebyshev and cosine.

Note: I will add more distances in the near future. If you need any distance in particular, open an issue.

import numpy as np
from hausdorff import hausdorff

# two random 2D arrays (second dimension must match)
np.random.seed(0)
X = np.random.random((1000,100))
Y = np.random.random((5000,100))

# Test computation of Hausdorff distance with different base distances
print("Hausdorff distance test: {0}".format( hausdorff(X, Y, distance="manhattan") ))
print("Hausdorff distance test: {0}".format( hausdorff(X, Y, distance="euclidean") ))
print("Hausdorff distance test: {0}".format( hausdorff(X, Y, distance="chebyshev") ))
print("Hausdorff distance test: {0}".format( hausdorff(X, Y, distance="cosine") ))

py-hausdorff's People

Contributors

mavillan avatar

Watchers

yinhang2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.