Extracts color, coverage, and complexity metrics from an artwork image for portfolio-relative benchmarking. Use this after artwork upload to generate the metrics stored in `artwork_stats`. The returned metrics feed into `artutils::update_artist_benchmarks()` for percentile calculations.
This is a pure computation function - it takes raw inputs and returns metric values without database interaction. The caller is responsible for adding identifiers and persisting results.
Arguments
- img_path
Character. Absolute path to the artwork image file (PNG, JPG). Typically the `main.png` exported from Procreate. The image is resized to 1000px width for analysis - original file is not modified.
- file_sz
Numeric. Image file size in bytes. Obtain from `file.info(path)$size` or the upload metadata. Used for bits-per-stroke and bits-per-color complexity metrics.
- draw_mins
Numeric. Total drawing time in minutes. Obtain from Procreate stats extraction (`duration_min` field). Used for time-based productivity metrics like strokes-per-second.
- strokes
Integer. Total brush stroke count. Obtain from Procreate stats extraction (`brush_strokes` field). Used for precision and complexity metrics.
Value
data.table with two columns: - `metric_key`: Character. The metric identifier (database column name) - `value`: Numeric. The computed metric value
Core metrics returned (used in benchmark scoring): - `canvas_coverage`: Percentage of canvas with color (0-100) - `n_unique_colors`: Unique color count in palette - `share_of_spectrum`: Proportion of RGB color space used (0-1) - `ave_blend_rate`: Blending smoothness indicator - `ave_colors_pstroke`: Colors created per brush stroke - `q75_color_freq`: 75th percentile of color frequency distribution
Extended metrics (stored for future analytics): - `count_dom_colors`, `q25_color_freq`, `q50_color_freq` - `ave_bits_psec`, `ave_strokes_psec`, `ave_colors_psec` - `ave_bits_pstroke`, `ave_bits_pcolor`
See also
- [get_metric_definitions()] for complete metric framework - [get_image_rast()] to extract raster data separately
Other metrics:
get_image_rast(),
metric-constants
Examples
if (FALSE) { # \dontrun{
# Compute metrics for an artwork
metrics <- calc_art_metrics(
img_path = "/path/to/artwork/main.png",
file_sz = 1500000,
draw_mins = 120,
strokes = 45000
)
# Add identifiers before database insert
metrics[, `:=`(
art_uuid = "99a61148-1d3b-4340-8cf6-92ad26046b0f",
artist_uuid = "746b8207-72f5-4ab6-8d19-a91d03daec3d",
created_utc = Sys.time()
)]
} # }
