Skip to Content

ObjSelect {ImageMetrics}

Selects objects from within an image
Package: 
ImageMetrics
Version: 
0.6

Description

ObjSelect selects an object with the polygon provided from an image.

Usage

ObjSelect(image,poly)

Arguments

image
the "@X" array of an imageMatrix object
poly
an a polygon represented as a vector of concatenated x coordinates and y coordinates

Values

A matrix or three dimensional array representing only the object in the image. All pixels not in the polygon are set to NA.

Note

This function relies on the maps package's point-in-polygon c-code for rapid selection

Examples

data(Campaign2008)
 
## User clicks around an object via tcktk device to define a polygon:
clinton = new("imageMatrix", X = readPNG(system.file("extdata", "Clinton.png", package="ImageMetrics")), type = "rgba")
 
# Select object using polygon:
clintonfacearray = ObjSelect( image = clinton@X, poly= clintonpoly )
 
# create new image with only the object selected.
clintonface = new("imageMatrix", X = clintonfacearray, type = "rgb")
 
 
## Not run:
plot(clintonface)
## End(Not run)

Author(s)

Solomon Messing <[last-name] at stanford dot edu>

Documentation reproduced from package ImageMetrics, version 0.6. License: BSD