
Calculate Morphometric Indices and Measurements
Source:R/morphometrics.R
calculate_morphometrics.RdComputes standard otolith morphometric measurements (Area, Perimeter, Length, Width) and shape indices (Roundness, Circularity, etc.) based on Tuset et al. (2003) formulas. The function supports scale conversion from pixels to millimeters if a `pixels_per_mm` value is provided.
Value
A named list containing:
Area: Surface area of the otolith.Perimeter: Length of the otolith boundary.Length: Maximum dimension (major axis).Width: Minimum dimension (minor axis).Units: Measurement units ("px" or "mm").Roundness: (4 * Area) / (pi * Length^2).FormFactor: (4 * pi * Area) / Perimeter^2.Circularity: Perimeter^2 / Area.Rectangularity: Area / (Length * Width).Ellipticity: (Length - Width) / (Length + Width).AspectRatio: Length / Width.
Examples
# Example using the built-in Aphanopus dataset
data(Aphanopus)
# Note: For internal calculation, you would typically pass the raw coordinates.
# Here we illustrate the function with sample coordinates from the package:
image_path <- system.file("extdata", "otolith.jpg", package = "aforoR")
binary_img <- preprocess_image(image_path)
contour <- extract_contour(binary_img)
metrics <- calculate_morphometrics(contour, pixels_per_mm = 100)
print(metrics)
#> $Area
#> [1] 9.7628
#>
#> $Perimeter
#> [1] 12.89881
#>
#> $Length
#> [1] 5.025411
#>
#> $Width
#> [1] 2.72705
#>
#> $Units
#> [1] "mm"
#>
#> $Roundness
#> [1] 0.4921996
#>
#> $FormFactor
#> [1] 0.7373687
#>
#> $Circularity
#> [1] 17.04218
#>
#> $Rectangularity
#> [1] 0.7123766
#>
#> $Ellipticity
#> [1] 0.2964686
#>
#> $AspectRatio
#> [1] 1.842801
#>