Learn R Programming

RImageJROI (version 0.1.3)

plot.ijroi: Plot ijroi object

Description

Plots ImageJ ROI objects using the 'base' graphics package.

Usage

# S3 method for ijroi
plot(x, add = FALSE, xlab = "", ylab = "", main = "", asp = 1, ...)

Arguments

x

The ijroi object.

add

Whether to add to an existing plot.

xlab

a title for the x axis: title.

ylab

a title for the y axis: title.

main

an overall title for the plot: title.

asp

numeric defining the aspect ratio y/x: see plot.window. Defaults to 1.

...

Additional parameters.

Author

David Sterratt, Mikko Vihtakari

Details

ImageJ ROI objects created with following tools are plotted using following graphics commands:

  • Rectangle tool ("rect") rect. Plotted based on coordinates.

  • Oval selections ("oval") polygon. Plotted based on equation.

  • Freehand selections ("freehand") lines. Plotted based on coordinates.

  • Elliptical selections ("freehand", "ELLIPSE") lines. Plotted based on equation.

  • Point Tool and Multi-Point Tool ("point") points. Plotted based on coordinates.

  • Straight Line ("line") lines. Plotted based on coordinates.

  • Arrow tool ("line", "ARROW") arrows. Plotted based on coordinates. Stroke width passed to lwd argument.

  • Segmented Line ("polyline") lines. Plotted based on coordinates.

  • Freehand Line ("freeline") lines. Plotted based on coordinates.

All graphics allow the additional parameters from appropriate functions. Aspect ratio (asp) is 1 by default leading to correct representation of ImageJ objects. If correct representation is not important, set asp = NA to use the R base-graphics default setting.

See Also

read.ijroi, read.ijzip, plot.ijzip

Examples

Run this code
# type 0 'polygon' ROIs are plotted using lines()
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "polygon.roi")
x <- read.ijroi(file)
plot(x, col = "red")

# type 1 'rect' ROIs are plotted using rect()
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "rect.roi")
x <- read.ijroi(file)
plot(x, border = "red")

# type 2 'oval' ROIs are plotted using polygon()
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "oval.roi")
x <- read.ijroi(file)
plot(x, border = "red")

# type 3 'line' ROIs (among others listed in 'details') are plotted using lines()
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "line.roi")
x <- read.ijroi(file)
plot(x, col = "red")

# type 3 arrows are a subtype of 'line'. Plotted using arrows(). The stroke width is
# carried over. To change width, use lwd argument
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "arrow.roi")
x <- read.ijroi(file)
plot(x, col = "red")

# type 4 'freeline' ROIs are plotted using lines()
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "freehand_line.roi")
x <- read.ijroi(file)
plot(x, col = "red")

# type 5 'polyline' ROIs are plotted using lines()
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "segmented_line.roi")
x <- read.ijroi(file)
plot(x, col = "red")

# type 7 'freehand' selection ROIs are plotted using lines()
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "freehand_selection.roi")
x <- read.ijroi(file)
plot(x, col = "red")

# type 7 Objects created using 'Elliptical selections' tool are also saved as
# 'freehand', but with subtype 'ELLIPSE'. The coordinates for this type are flawed
# and plotting is done using equation for an ellipse
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "elliptical.roi")
x <- read.ijroi(file)
plot(x, border = "red")
lines(x$coords[,1], x$coords[,2]) ## plotted based on coordinates.

# type 10 'point' ROIs are plotted using points()
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "multi_point.roi")
x <- read.ijroi(file)
plot(x, col = "red")

# If following is shown as a (round) circle, asp = 1
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "circle.roi")
x <- read.ijroi(file)
plot(x, border = "red")

# text is stored as type 'rect' with subtype 'TEXT'. Currently
# only the outlining rectangle is returned
file <- file.path(system.file(package = "RImageJROI"), "extdata", "ijroi", "text.roi")
x <- read.ijroi(file)
plot(x, border = "red")

Run the code above in your browser using DataLab