Skip to contents

Prepares an image for shape analysis by applying grayscale conversion, Gaussian smoothing to reduce noise, and binarization using the Otsu method (default) or a fixed threshold.

Usage

preprocess_image(image_path, threshold = NULL, blur_size = 31, blur_sigma = 9)

Arguments

image_path

A string specifying the path to the image file (e.g., .jpg, .png, .tiff) OR an EBImage object.

threshold

A numeric value (0-1) for binarization. If NULL, Otsu's method is automatically applied.

blur_size

Size of the Gaussian brush for smoothing (default: 31).

blur_sigma

Sigma of the Gaussian brush for smoothing (default: 9).

Value

A pixset (EBImage) representing the binarized image.

Examples

# Use the sample otolith image included in the package
image_path <- system.file("extdata", "otolith.jpg", package = "aforoR")
processed_img <- preprocess_image(image_path)
# display(processed_img) # if using EBImage