cropimage {LS2Wstat} | R Documentation |
Crops a rectangular image to a specified (square) dimension
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
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 |
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 |
Author(s)
Matt Nunes
See Also
Examples
#
#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)
#