Friday, April 4, 2014

Creating a checkerboard pattern

This section demonstrates how to create a checkerboard pattern using the R package StereoMorph. Before beginning, be sure that you have installed R and the StereoMorph package (see installing R packages).

1. Begin by loading the StereoMorph library into the current R session.


2. We’ll create a checkerboard pattern by calling the function drawCheckerboard(). First, specify a filename for the checkerboard image. We'll make a checkerboard with 8 internal corners along one dimension and 6 along the other, with a square size of 180 pixels.

filename <- 'Checkerboard 8x6 (180px).JPG'

3. Call drawCheckerboard().

drawCheckerboard(nx=8, ny=6, square.size=180, filename)

The image will be saved to the current working directory.
An 8x6 checkerboard pattern created by drawCheckerboard().
Note that 'nx' and 'ny' are the numbers of internal corners along the horizontal and vertical axes, respectively, not the number of squares. If you're performing automated corner detection, the internal corner count is what matters because it’s actually the internal corners that will be extracted.

4. Print the pattern at 10% scaling (see Measuring checkerboard square size). Any decent printer will do - for this tutorial I used an HP Deskjet F4200. If you print at 10% scaling and 72 dpi (the standard) your squares should measure 0.25 inches on each side. Note that the smaller the scaling, the sharper the edges will appear when printed.

If you would like to create a standard checkerboard pattern (i.e. the ones used for playing checkers) make 'nx' and 'ny' both 7 since checkerboards have 7 internal corners along each dimension.

filename <- 'Checkerboard 7x7 (180px).JPG'
drawCheckerboard(nx=7, ny=7, square.size=180, filename)

This will make a checkerboard with 8x8 squares.

A checkerboard pattern with 7x7 internal corners (8x8 squares) created by drawCheckerboard().

No comments:

Post a Comment