circularity: Measure circularity of a circle in an image

Description Usage Arguments Details Value References Examples

View source: R/perfectcircle.R

Description

Measure circularity of a circle in an image

Usage

1
circularity(warp, seedPoints, progress, verbose = FALSE)

Arguments

warp

The rectified image containing the circle

seedPoints

A data.frame containing the (x, y) coordinates of type=="foreground" and type=="background" pixels.

progress

A shiny progress bar. If NULL the argument is ignored. Otherwise, progress of the steps is communicated via a shiny progress bar.

Details

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

Value

A list containing several elements

outfile

File name (with path) of the image containing both the extracted freehand circle and the best fitting circle

outfile_intermediate

File name (with path) containing the intermediate results

area

Area of the disc made up by the freehand circle

ratio_area

Ratio between the above area and the corresponding area of the perfect circle. 1 is optimial

area_difference

Summing up all points inside and outside the perfect circle weighted by distance (see blog post for details)

score

Corresponds to (1-ratio_areadifference)*100. The optimal value is 100%.

References

Höhle, M. (2018), Judging Freehand Circle Drawing Competitions.

Examples

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

hoehleatsu/perfectcircle documentation built on Feb. 6, 2020, 10:13 p.m.