Learn R Programming

velox (version 0.2.0)

VeloxRaster_im2col: im2col

Description

Creates a matrix of flattened image patches from a VeloxRaster band. Order is left-to-right, top-to-bottom. Note that if any(c(rowframe, colframe)>0), the image patches are (partially) overlapping.

Arguments

wrow

Patch size in the y dimension.

wcol

Patch size in the x dimension.

band

The band to be flattened.

padval

A padding value.

rowframe

A non-negative integer specifying the size of the frame around the image patches in the y dimension.

colframe

A non-negative integer specifying the size of the frame around the image patches in the x dimension.

rowstride

A positive integer denoting the stride between extracted patches in the y dimension. I.e. only every rowstrideth patch is extracted.

colstride

A positive integer denoting the stride between extracted patches in the x dimension. I.e. only every colstrideth patch is extracted.

Value

A numeric matrix with (wrow+2*rowframe)*(wcol+2*colframe) columns.

Examples

Run this code
# NOT RUN {
## Make VeloxRaster
mat <- matrix(1:100, 10, 10)
vx <- velox(mat, extent=c(0,1,0,1), res=c(0.1,0.1), crs="+proj=longlat +datum=WGS84 +no_defs")
## Apply im2col
patch.mat <- vx$im2col(wrow=2, wcol=2, band=1, padval=0,
                       rowframe=1, colframe=1, rowstride=2, colstride=2)
dim(patch.mat)

# }

Run the code above in your browser using DataLab