read.ufmf: Read frame from a ufmf format movie

Description Usage Arguments Details Value See Also Examples

View source: R/read.ufmf.frame.R

Description

Read frame from a ufmf format movie

Usage

1
read.ufmf(x, framei = NULL, return.boxes = FALSE)

Arguments

x

Either a path to a file on disk, a connection or a parsed ufmf header object (as returned by read.ufmf.header)

framei

Integer index of the frame to read

return.boxes

Whether to return an matrix describing the position of pixels that differ from the mean image (see details, default FALSE).

Details

When reading multiple frames, the recommended idiom is to read the header and store it in an object, then pass that object to read.ufmf along with the integer index of the required frame. See examples.

When present, bounding boxes for foreground pixels are returned in an N x 4 matrix where the four columns specify (x, y, width , height).

Value

An array/matrix containing the image data with the frame timestamp and (optionally) boxes as attributes. MONO8 data will be returned as width x height matrix, while RGB8 data will be a width x height x 3 array.

See Also

connection, read.ufmf.header

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
h=read.ufmf.header("movie.ufmf")
frames=lapply(1:5, function(i) read.ufmf(h, i))

## Show foreground boxes
f5=read.ufmf(h, 5, return.boxes=TRUE)
# plot image with integer pixel indices for x and y axes (rather than 0-1)
image(1:nrow(f5), 1:ncol(f5), f5, useRaster = T)
bb=attr(f5, "boxes")
# plot rectangles for foreground boxes
rect(bb[,1], bb[,2], bb[,1]+bb[,3], bb[,2]+bb[,4])

## End(Not run)

jefferis/fmfio documentation built on May 19, 2019, 2:50 a.m.