cropimage: Crops a rectangular image to a specified (square) dimension

Description Usage Arguments Details Value Author(s) See Also Examples

Description

If the input image is not of dimension 2^n \times 2^n, for some n, then the image is cropped to an optionally specified size.

Usage

1
cropimage(image, newsize = NULL, pos = "e")

Arguments

image

The image you wish to crop.

newsize

An optional dimension (smaller than the original image dimension), to which the image should be cropped.

pos

The position of the subimage to take when cropping an image. See the documentation for mix2images for more details.

Details

As we often wish to work with images whose dimensions are some power of 2, this function will determine whether the image is of an appropriate size and if not it will crop the image so that it is. The optional pos argument specifies the position of the cropped subimage to be returned; for example pos="e" specifies the central region. See mix2images for more details on the positioning argument.

Value

subim

A square image with dimension 2^n \times 2^n, where n is either newsize or the largest feasible dyadic power smaller than the original image dimensions.

Author(s)

Matt Nunes

See Also

mix2images

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#
#Create an image with dimensions not a power of two
#
testimage <- matrix(rnorm(300^2),nrow=300,ncol=300)
#
#Crop the image
#
Newimage <- cropimage(testimage)
#
# Check new dimension size.
#
dim(Newimage)
#        

LS2Wstat documentation built on May 2, 2019, 5:45 a.m.