The initial approach towards scoring free hand circle orignates from the blog post Judging Freehand Circle Drawing Competitions. The code of this post now developed into the present package. It contains an API for the scoring algorithms and a shiny app, which can be used without any technical knowledge. Please visit the github pages of the package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | library(purrr)
library(dplyr)
scaleFactor <- 50
img_list <- list.files( path=system.file("extdata", package="perfectcircle"), pattern="*.jpg")
##Compute the circularity scores for the entire batch of jpg files located in a certain directory.
leaderboard <- map_df(img_list, ~ {
cat("Processing: ", .x, "\n")
#Load image and coordinates
file_path <- system.file("extdata", .x, package="perfectcircle")
img <- imager::load.image(file_path)
seedPoints <- read.csv(file=gsub("\\.jpg$","\\.csv", file_path))
names(seedPoints) <- NULL
##Scale
img <- imager::resize(img, -scaleFactor, -scaleFactor)
seedPoints[,1:2] <- as.matrix(seedPoints[,1:2]) * scaleFactor/100
##Measure
res <- perfectcircle::circularity(warp=img, seedPoints=seedPoints, progress=NULL)
res$fileName <- gsub("\\.csv","", .x)
res
})
#Leaderboard
leaderboard %>% arrange(desc(score)) %>% select(score, fileName, ratio_area)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.