ObjSelect: Selects objects from within an image

Description Usage Arguments Value Note Author(s) Examples

Description

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

Usage

1

Arguments

image

the "@X" array of an imageMatrix object

poly

an a polygon represented as a vector of concatenated x coordinates and y coordinates

Value

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

Author(s)

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)

SolomonMg/ImageMetrics documentation built on May 27, 2019, 7:39 a.m.