patRegK: Aligns images using 'niftyreg' utilities for automated image...

View source: R/patRegK.R

patRegKR Documentation

Aligns images using niftyreg utilities for automated image registration and extracts colors using k-means clustering.

Description

Aligns images using niftyreg utilities for automated image registration and extracts colors using k-means clustering.

Usage

patRegK(
  sampleList,
  target,
  k = 3,
  fixedStartCenter = NULL,
  resampleFactor = NULL,
  useBlockPercentage = 75,
  crop = c(0, 0, 0, 0),
  removebgR = NULL,
  removebgK = NULL,
  maskOutline = NULL,
  maskColor = 0,
  plot = FALSE,
  focal = FALSE,
  sigma = 3
)

Arguments

sampleList

List of RasterStack objects.

target

Image imported as RasterStack used as target for registration.

k

Integere for defining number of k-means clusters (default = 3).

fixedStartCenter

Specify a dataframe with start centers for k-means clustering.

resampleFactor

Integer for downsampling used by redRes (default = NULL).

useBlockPercentage

Block percentage as used in niftyreg (default = 75).

crop

Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image.

removebgR

Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for registration analysis. This works only to remove a white background.

removebgK

Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for k-means analysis. This works only to remove a white background.

maskOutline

When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL).

maskColor

Color the masked area gets. Set to 0 for black (default) or 255 for white.

plot

Whether to plot k-means clustered image while processing (default = FALSE).

focal

Whether to perform Gaussian blurring (default = FALSE).

sigma

Size of sigma for Gaussian blurring (default = 3).

Value

List of rasters for each k-means cluster objects.

Examples

IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004')
prepath <- system.file("extdata",  package = 'patternize')
extension <- '.jpg'

imageList <- makeList(IDlist, 'image', prepath, extension)

target <- imageList[[1]]

## Not run: 
rasterList_regK <- patRegK(imageList[3], target, k = 5,
crop = c(100,400,40,250), removebgR = 100, plot = TRUE)

## End(Not run)


patternize documentation built on Aug. 22, 2023, 5:07 p.m.