identifyParticles: Identify moving particles

identifyParticlesR Documentation

Identify moving particles

Description

identifyParticles identifies moving particles using the subtracted images obtained from subtractBackground. Function uses Connected Component Labeling and obtains particle statistics based on code developed for the orphaned package SDMTools (written by Jeremy VanDerWal).

Usage

identifyParticles(
  sbg,
  threshold = -0.1,
  pixelRange = NULL,
  qthreshold = NULL,
  select = "dark",
  colorimages = NULL,
  autoThres = FALSE,
  perFrame = FALSE,
  frames = NULL
)

Arguments

sbg

Array containing images containing all moving particles, as obtained from subtractBackground.

threshold

Thresholds for including particles. A numeric vector containing three values; one for each color. Otherwise, supply one value which is to be used for all three colors. For a chosen quantile for each frame, use qthreshold. Default is threshold=-0.1, which works for dark particles on a light background. Alternatively, set autoThres below for an automatic threshold.

pixelRange

Default is NULL. Numeric vector with minimum and maximum particle size (area), used as a first filter to identify particles. Use if particle of interest are of a known size range (in pixels).

qthreshold

Default is NULL. Supply a value, to do thresholding based on quantile. Quantile is calculated for each frame separately.

select

Select dark particles ('dark'), light particles ('light'), or both ('both'), compared to background. Default is 'dark'.

colorimages

Array containing original color images. By default, the original color images are obtained from global environment.

autoThres

Logical. TRUE to get an automated threshold for each color layer. Default is FALSE.

perFrame

Logical. If autoThres=TRUE, set at TRUE to calculate a threshold for each frame separately. Default is FALSE. Note that is can be computationally intensive to calculate a threshold for each frame.

frames

When autoThres=TRUE and allFrames=FALSE, supply a numeric vector specifying over which frames the automated threshold should be calculated on (e.g. c(1,3,5,7,9,11) for all odd frames from 1 to 11).

Value

Returns a dataframe of class 'TrDm' and 'particles', containing particle statistics with identified particles for each frame

Author(s)

Marjolein Bruijning, Caspar A. Hallmann & Marco D. Visser

Examples

## Not run: 
dir.create("images")
## Create image sequence
traj <- simulTrajec(path="images",
                    nframes=30,nIndividuals=20,domain="square",
                    h=0.01,rho=0.9,
                    sizes=runif(20,0.004,0.006))
## Load images
dir <- "images"
allFullImages <- loadImages (dirPictures=dir,nImages=1:30)
stillBack <- createBackground(allFullImages,method="mean")
allImages <- subtractBackground(stillBack)
partIden <- identifyParticles(allImages,threshold=-0.1,
                                   pixelRange=c(3,400))
plot(partIden)
summary(partIden)

## End(Not run)

trackdem documentation built on May 29, 2024, 7:43 a.m.