Calculate convexity as the ratio of convex hull perimeter to shape perimeter.
Value
If
xis a single matrix: returns a numeric scalarIf
xis a list: returns a numeric vectorIf
xis a tibble: returns a numeric vector extracted from coo column
Details
Convexity = Perimeter(convex_hull) / Perimeter(shape). Value of 1 for convex shapes. Lower values indicate concavities.
Examples
get_convexity(shapes$cat)
#> [1] 0.7305908
# Use in measure()
bot %>% measure("convexity")
#> # A tibble: 40 × 4
#> coo type dummy coo_convexity
#> <out> <fct> <fct> <dbl>
#> 1 (138 x 2) whisky a 0.991
#> 2 (168 x 2) whisky a 0.990
#> 3 (189 x 2) whisky a 0.985
#> 4 (129 x 2) whisky a 0.993
#> 5 (152 x 2) whisky a 0.989
#> 6 (161 x 2) whisky a 0.987
#> 7 (124 x 2) whisky a 0.995
#> 8 (126 x 2) whisky a 0.985
#> 9 (183 x 2) whisky a 0.986
#> 10 (193 x 2) whisky a 0.993
#> # ℹ 30 more rows
