extractImagePatches: Extract 2-D or 3-D image patches.

View source: R/extractImagePatches.R

extractImagePatchesR Documentation

Extract 2-D or 3-D image patches.

Description

Extract 2-D or 3-D image patches.

Usage

extractImagePatches(
  image,
  patchSize,
  maxNumberOfPatches = "all",
  strideLength = 1,
  maskImage = NULL,
  randomSeed,
  returnAsArray = FALSE,
  randomize = TRUE
)

Arguments

image

Input ANTs image with one or more components.

patchSize

Width, height, and depth (if 3-D) of patches.

maxNumberOfPatches

Maximum number of patches returned. If "all" is specified, then all patches in sequence (defined by the strideLength are extracted.

strideLength

Defines the sequential patch overlap for maxNumberOfPatches = "all". Can be a image-dimensional vector or a scalar.

maskImage

optional image specifying the sampling region for the patches when maximumNumberOfPatches does not equal "all". The way we constrain patch selection using a mask is by forcing each returned patch to have a masked voxel at its center.

randomSeed

integer seed that allows reproducible patch extraction across runs.

returnAsArray

specifies the return type of the function. If FALSE (default) the return type is a list where each element is a single patch. Otherwise the return type is an array of size dim( numberOfPatches, patchSize ).

randomize

boolean controlling whether we randomize indices when masking.

Value

a list (or array) of image patches.

Author(s)

Tustison NJ

Examples


library( ANTsR )

image <- antsImageRead( getANTsRData( "r16" ) )
maskImage <- getMask( image, 1, 1000 )
patchSet1 <- extractImagePatches( image, c( 32, 32 ), 10, c( 32, 32 ), randomSeed = 0 )
patchSet2 <- extractImagePatches( image, c( 32, 32 ), 10, c( 32, 32 ), randomSeed = 1 )
patchSet3 <- extractImagePatches( image, c( 32, 32 ), 10, c( 32, 32 ), maskImage, randomSeed = 0 )


ANTsX/ANTsRNet documentation built on Nov. 21, 2024, 4:07 a.m.