Skip to contents

This function processes images in a specified folder, applying various transformations and analyses.

Usage

process_images(
  folder,
  subfolder = FALSE,
  threshold = NULL,
  wavelets = TRUE,
  ef = TRUE,
  testing = TRUE,
  pseudolandmarks = "both",
  save = TRUE,
  pixels_per_mm = NULL,
  detect_scale = FALSE,
  blur_size = 31,
  blur_sigma = 9,
  min_points = 200,
  min_area = 5000,
  n_harmonics = 32,
  n_points = 512,
  scale_mm = 1,
  procrustes = FALSE
)

Arguments

folder

A string specifying the path to the folder containing images. Supported formats include `.jpg`, `.jpeg`, `.png`, `.tif`, and `.tiff`.

subfolder

A logical value indicating whether the folder has subfolders.

threshold

A numeric value for binarization. If not provided, the Otsu method is used.

wavelets

A logical value indicating whether to obtain wavelets. Default is TRUE.

ef

A logical value indicating whether to obtain elliptic Fourier descriptors. Default is TRUE.

testing

A logical value indicating whether to save test images. Default is TRUE.

pseudolandmarks

A string specifying the type of pseudolandmarks. Options are 'curvilinear', 'polar', 'both'. Default is 'both'.

save

A logical value indicating whether to save the results as CSV files. Default is TRUE.

pixels_per_mm

A numeric value specifying the scale (pixels per mm). Default is NULL.

detect_scale

A logical value indicating whether to automatically detect the scale bar in the image. Default is FALSE.

blur_size

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

blur_sigma

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

min_points

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

min_area

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

n_harmonics

Number of elliptic Fourier harmonics to calculate (default: 32).

n_points

Target number of points for resampling (default: 512).

scale_mm

Total length in mm of the scale bar for detection (default: 1).

procrustes

A logical value indicating whether to apply Generalized Procrustes Analysis (GPA) to align all extracted contours before calculating shape descriptors. Default is FALSE.

Value

Invisible NULL. The function is used for its side effects (creating files).

Details

The function generates the following files in the `Polar` (and `Cartesian`) directories:

  • MorphometricsEN.csv: Table with morphometric measures (Area, Perimeter, Length, Width).

  • DistanciaEN.csv and Distancia_NormEN.csv: Raw and normalized distances (radii or perimeter).

  • Wavelet_xEN.csv: Wavelet coefficients for scales 1 to 9.

  • EllipticCoeEN.csv: Elliptic Fourier coefficients (if ef = TRUE).

  • Coords.csv: Contour coordinates.

If testing = TRUE, diagnostic images are also saved:

  • zonal_[ImageName].jpg: Visualization of the contour and analysis sectors.

  • wavelet_[ImageName].jpg: Visualization of the wavelet transform.

Examples

if (FALSE) { # \dontrun{
# Process all images in the "images" folder
process_images(folder = "path/to/images", pixels_per_mm = 100)
} # }