Skip to Content

setObjPoly {ImageMetrics}

Interface to select objects within an image
Package: 
ImageMetrics
Version: 
0.6

Description

setObjPoly pulls up a tcltk interface for the user to select an object from the image. getObjPoly returns the coordinates the user selected.

Usage

setObjPoly(image)
getObjPoly(image)

Arguments

image
an imageMatrix object

Values

A vector of x coordinates and y coordinates corresponding to the object selected in the image.

Note

These two functions are used to hand-select an object in an image, so that metrics can be extracted. Thanks to http://www.sciviews.org/_rgui/tcltk/InteractiveTkrPlot.html, which outlines many key concepts used for these functions.

Examples

## Not run:
    mcattackad = new("imageMatrix", X = readPNG(system.file("extdata", "jm-sep25-promise1.png", package="ImageMetrics")), type = "rgba")
    setObjPoly(mcattackad) ## opens tcltk interface
    mcattackadpoly = getObjPoly(mcattackad) ## returns polygon corresponding to the object the user selected.
 
    ## create new image with only the object selected.
    mcattackadface = new("imageMatrix", X = ObjSelect( image = mcattackad@X, poly= mcattackadpoly ), type = "rgb")
    plot(mcattackadface)
 
    ## save the image to the current directory
    getwd() 
    writePNG(mcattackadface@X, "obamaface.png")## End(Not run)

Author(s)

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

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