Julia library for calculating concave hulls
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
src
test
.codecov.yml
.gitignore
.travis.yml
LICENSE.md
README.md
REQUIRE

README.md

ConcaveHull

Build Status

This package computes the concave/convex hull of a set of points using a nearest neighbours algorithm[1].

[1] Moreira, Adriano, and Maribel Yasmina Santos. "Concave hull: A k-nearest neighbours approach for the computation of the region occupied by a set of points." (2007).

Usage

Pkg.add("ConcaveHull") # Add package
using ConcaveHull
using Plots

points = [[th, -sin(th)] .+ (0.4*rand(2) - 0.2) for th in linspace(0,2pi,5000)];
x = [p[1] for p in points];
y = [p[2] for p in points];

hull = concave_hull(points)
hull_area = area(hull)

scatter(x,y,ms=1,label="",axis=false,grid=false,markerstrokewidth=0.0)
plot!(hull)
annotate!(pi/2,0.5,"K = $(hull.k)")
annotate!(pi/2,0.25,"Area $(round(hull_area,3))")

Smoothness

The smoothness of the concave hull can be adjusted by increasing the number of neighbours used

hull = concave_hull(points,100) # Use 100 neighbours
hull_area = area(hull)

scatter(x,y,ms=1,label="",axis=false,grid=false,markerstrokewidth=0.0)
plot!(hull)
annotate!(pi/2,0.5,"K = $(hull.k)")
annotate!(pi/2,0.25,"Area $(round(hull_area,3))")