Learn R Programming

StereoMorph (version 1.6.7)

drawCheckerboard: Creates a checkerboard image

Description

Creates a checkerboard image of specified dimensions and saves to an input file path. The dimensions of the checkerboard are specified by the number of internal corners (the number of squares minus one).

Usage

drawCheckerboard(nx, ny, square.size, file = NULL, 
                 margin.x = c(round(square.size/2), round(square.size/2)),
                 margin.y = c(round(square.size/2), round(square.size/2)),
                 filename = NULL, ...)

Arguments

nx

the number of internal corners in the horizontal direction (the number of squares in each row minus one).

ny

the number of internal corners in the vertical direction (the number of squares in each column minus one).

square.size

the square size in pixels.

file

the file path and name to which the image should be saved. The filename must be a valid image filename. Acceptable extensions are: jpg, jpeg, bmp, png and tiff.

margin.x

the margin in pixels on the left and right sides of the checkerboard pattern.

margin.y

the margin in pixels on the top and bottom of the checkerboard pattern.

filename

Duplicate with file. Included for backward compatibility with previous version.

...

further arguments to be passed to the image function corresponding to the extension in filename (e.g. compression, quality, etc.).

Value

returns null device

Details

This function requires the grid package. The image type is determined automatically from the filename and the corresponding image writing function is called.

See Also

readCheckerboardsToArray

Examples

Run this code
# NOT RUN {
## NUMBER OF INTERNAL CORNERS IN THE HORIZONTAL DIMENSION
## NUMBER OF ROWS OF SQUARES MINUS ONE
nx <- 21

## NUMBER OF INTERNAL CORNERS IN THE VERTICAL DIMENSION
## NUMBER OF COLUMNS OF SQUARES MINUS ONE
ny <- 14

## SQUARE SIZE IN PIXELS
square.size <- 200

## WHERE TO SAVE THE FILE
filename <- paste0("checkerboard_", nx, "_", ny, "_", square.size, ".jpeg")

# }
# NOT RUN {
## DRAW CHECKERBOARD
## FILE WILL BE CREATED IN CURRENT WORKING DIRECTORY
drawCheckerboard(nx=nx, ny=ny, square.size=square.size, filename=filename)
# }

Run the code above in your browser using DataLab