if (FALSE) {
# generate annulus data
data_annulus <- data.frame(matrix(data=runif(4000),ncol=2))
names(data_annulus) <- c("x","y")
data_annulus <- subset(data_annulus,
sqrt((x-0.5)^2+(y-0.5)^2) > 0.4 & sqrt((x-0.5)^2+(y-0.5)^2) < 0.5)
# MAKE HYPERVOLUME (low reps for fast execution)
hv_annulus <- hypervolume_gaussian(data_annulus,
kde.bandwidth=0.05,name='annulus',samples.per.point=1)
# GET CONVEX EXPECTATION
hv_convex <- expectation_convex(hypervolume_thin(hv_annulus,num.samples=500),
check.memory=FALSE,use.random=TRUE)
# DETECT HOLES (low npoints for fast execution)
features_annulus <- hypervolume_holes(
hv.obs=hv_annulus,
hv.exp=hv_convex,
set.check.memory=FALSE)
# CLEAN UP RESULTS
features_segmented <- hypervolume_segment(features_annulus,
check.memory=FALSE,distance.factor=2)
features_segmented_pruned <- hypervolume_prune(features_segmented,
volume.min=0.02)
# PLOT RETAINED HOLE(S)
plot(hypervolume_join(hv_annulus, features_segmented_pruned))
}
Run the code above in your browser using DataLab