## The perfect circle!

By M. HÃ¶hle based on the algorithm described in Judging Freehand Circle Drawing Competitions .

### Circularity Score:

The points:
Note: Both images are shown at a 25% scale of the size used in the calculations.

## The App

The R source code of The perfect circle shiny app is available as part of the R package perfectcircle available from github under a GPLv3 license. Please posts comments and bugs as github issues . More information about the algorithm as well as the manual of the app can be found as part of the R package perfectcircle , e.g., on the Wiki page. Furthermore, two video tutorials of the shiny app are described in the blog post A Shiny app for your perfect circle .

## World Championship in Freehand Circle Drawing

Can you draw freehand circles like a World Champion? If yes, prove it by making a github pull request containing the files [Alias].jpg and [Alias].csv files to the round-1 folder of the worldfreehandcirclechampionship github project.

## Using the Shiny App

##### Image:
Select a rectified .jpg image of your circle using the file selector of the shiny app. Your image should be rectified - that means parallel lines should appear as parallel lines and 90 degree angles should display as 90 degree angles in the image. Such a picture can for example be obtained by placing the camera on a pod a few meters away from the center of your drawing canvas and on the line of an orthogonal vector from this center. Also ensure a constant lighting without reflections. Best results are obtained if there is a large contrast between circle and background, e.g., white chalk on a clean blackboard or black edding on a whiteboard. Note: The more pixels the uploaded contains the longer the computations take. It can thus be a good idea to use the scale factor slider to reduce the resolution in order to speed up the computations. Warning: Results for an image may vary slightly based on the selected scale factor. If one wants to compare the score of several different circles one should compare the scores at the same scaling.

##### Seed Points:
For the image the coordinates of at least two background and at least one foreground points have to be specified: For the background points at least one has to be placed inside the circle and at least one outside the circle. The seedpoints are specified in the 'Seed points' tab bei either clicking in the image (choosing the appropriate 'click action') or by uploading a .csv file with columns 'x', 'y' and 'type' (where type is either: foreground or background). The later allows the user to find the coordinates using her favorite image analysis program, e.g., Gimp or MS paint or directly in R using the 'locator' function. An example of such a .csv file is:

x,y,type
1304,1368,background
232,416,background
304,1304,foreground
2384,1304,foreground

It is possible to download the current selection of seed points as a .csv file (select: 'Download') in order to speed up the process a second time or to batch process an entire stack of images directly in R. Note: Displaying the image might take a little while, if the resolution is high. It can be beneficial to use a scale factor of 25% or lower in the main tab, because the image displayed is shown using the scale factor also and, hence, is faster.

##### Result:
Once you uploaded the two files and selected the scale factor you have to hit the 'Go!' button to start the computation. This will compute the circularity score by comparing with the perfect circle. The reported score is the `(1-ratio_areadifference)*100%` score described in Judging Freehand Circle Drawing Competitions . Details of the resulting fit are shown in the 'Fit Details' panel. This shows for example how the extraction of the circle from the background worked and if, possibly, more foreground or background seed points are needed to get better results. It is possible to change just the seed points and hit 'Go!' in order to improve the detection sequentially.