Skip to contents

Detects all contours in a binary image and identifies the largest one that meets specific size criteria (points > 200 and area > 5000), typically representing the fish otolith.

Usage

extract_contour(binary_image, min_points = 200, min_area = 5000)

Arguments

binary_image

A binarized image produced by preprocess_image().

min_points

Minimum number of points required for a valid contour (default: 200).

min_area

Minimum area required for a valid contour (default: 5000).

Value

A matrix of (X, Y) coordinates of the main contour, or NULL if no suitable contour is found.

Examples

# Process sample image and extract its contour
image_path <- system.file("extdata", "otolith.jpg", package = "aforoR")
binary_img <- preprocess_image(image_path)
contour <- extract_contour(binary_img)
head(contour)
#>      [,1] [,2]
#> [1,]  280   83
#> [2,]  279   84
#> [3,]  278   84
#> [4,]  277   84
#> [5,]  276   84
#> [6,]  275   84