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.
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).
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
