Learn R Programming

trackdem (version 0.6)

subtractBackground: Background subtraction

Description

subtractBackground subtracts each image from a previously created still background. The objects created through the function contain all changing pixels (i.e. movement).

Usage

subtractBackground(bg, colorimages = NULL)

Value

Returns array of class 'TrDm' and 'sbg' with same size as images, subtracted from background.

Arguments

bg

Array containing still background, as returned from createBackground.

colorimages

Array containing all frames, obtained by loadImages. Default is NULL, in this case the original images are used from the global environment.

Author

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

Examples

Run this code
if (FALSE) {
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)
plot(allImages)
}

Run the code above in your browser using DataLab