putROI | R Documentation |
Place a scaled image into another image as an optionally framed inset
putROI( img, roi, position, show, frac = NULL, mag = NULL, frac.default = 1/3, lwd = 2, col = "white" )
img |
the larger |
roi |
the smaller |
position |
a |
show |
|
frac |
a |
mag |
optional magnification factor for inset; if |
frac.default |
default fractional width for the inset ( |
lwd |
width of the inset border in pixels; note that this is
not the standard definition of |
col |
color of the inset border |
The image to be placed as an inset (roi
) will be scaled
and placed in img
at the location specified by position
.
This argument can be one of "topleft", "top", "topright", "left",
"center", "right", "bottomleft", "bottom", and "bottomright". The code
will also accept the integers 1 to 9 corresponding to these
respective positions. If position
is missing,
locator
will be called to determine where (among the
nine choices) to place the inset.
The image will be scaled according to either frac
or mag
where frac
indicates the fractional width of the image to be
occupied by the scaled inset. Alternatively, the magnification can be
specified with mag
, typically a number greater than 1. Values that
create an inset greater than the dimensions of the img
argument
will cause an error.
If show = TRUE
or if show
is missing and locator
was used to place the inset, the image with inset will be plotted. In all
cases, the modified image will be invisibly returned.
An Image
of the same dimensions as the second argument
(img
) with roi
inserted after appropriate scaling and
optional framing.
getROI
to get a region of interest from an image and
drawROI
to draw a frame within an image.
# Sample color image lighthouse <- readImage(system.file("extdata", "lighthouse.jpg", package="EBImageExtra")) # Get region of interest of fixed width and height, specified by center ins <- getROI(lighthouse, 515, 280, w = 180, h = 280) putROI(lighthouse, ins, "topright", show = TRUE) # Display the 9 possible positions img <- resize(lighthouse, w = 256) ins2 <- resize(ins, w = 45) z <- lapply(1:9, function(i) putROI(img, ins2, i, lwd = 4)) z <- abind(z, along = 4) # 5-times faster than calling 'combine' plotStack(z, labels = TRUE, cex = 1.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.