Description Usage Arguments Details Value References Examples
View source: R/perfectcircle.R
Measure circularity of a circle in an image
1 | circularity(warp, seedPoints, progress, verbose = FALSE)
|
warp |
The rectified image containing the circle |
seedPoints |
A |
progress |
A shiny progress bar. If |
Function executes the steps described in Judging Freehand Circle Drawing Competitions.
Note: Opposite to the description in the blog post we assume that the image is already rectified. The steps are thus:
1. Identify the freehand circle in the image using a watershed algorithm based on seedpoint coordinates in the image.
2. Fit a perfect circle to the freehand circle using a total least squares (TLS) argument. The optimization occurs using optim
.
3. Calculate the distance for each pixel on the freehand circle to the fitted perfect circle.
4. Sum of the distances.
The reported score is (1-r_{δ A})·100% where r_{Δ A} is the sum of the distances divided by the area of the fitted perfect circle, i.e. π · r².
A list containing several elements
File name (with path) of the image containing both the extracted freehand circle and the best fitting circle
File name (with path) containing the intermediate results
Area of the disc made up by the freehand circle
Ratio between the above area
and the corresponding area of the perfect circle. 1 is optimial
Summing up all points inside and outside the perfect circle weighted by distance (see blog post for details)
Corresponds to (1-ratio_areadifference)*100
. The optimal value is 100%.
Höhle, M. (2018), Judging Freehand Circle Drawing Competitions.
1 2 3 4 5 6 7 | img <- imager::load.image( system.file("extdata/", "localhost.jpg", package = "perfectcircle") )
seedPoints <- read.csv( system.file("extdata", "localhost.csv", package="perfectcircle"))
res <- perfectcircle::circularity(img, seedPoints, progress=NULL)
res
#Show the resulting file
plot(imager::load.file(res$outfile))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.