Calculate rectangularity as the ratio of area to bounding box area.
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
Rectangularity = Area / (Length × Width). Value of 1 for a perfect rectangle. Lower values indicate less rectangular shapes.
Examples
get_rectangularity(shapes$cat)
#> [1] 0.5527956
# Use in measure() on a mini bot for the sake of speed
bot[1:2, ] %>% measure("rectangularity")
#> # A tibble: 2 × 6
#> id coo type fake price coo_rectangularity
#> <chr> <out> <fct> <fct> <dbl> <dbl>
#> 1 brahma (138 x 2) whisky a 3 0.775
#> 2 caney (168 x 2) whisky a 1.2 0.777
