Learn R Programming

MRIaggr (version 1.1.5)

outline: Outline a region on a slice

Description

Tool for graphical definition of a spatial region on an image.

Usage

outline(n=50,sequential = TRUE, min_dist = 1, col = c("blue","red","grey"), pch = 20, cex = c(0.75,1,0.75))

Arguments

n
maximum number of points to define the outline. integer.
sequential
should the region edge be updated on the graphical device after each point ? logical.
min_dist
if the distance between the new point and the initial point is inferior to min_dist, then the definition of the region ends. numeric. Only active if sequential is TRUE.
col
the colors in which the user-defined edge points, the interpolated edge points and the interior points should be ploted. character vector of size 3.
pch
the symbol with which the observations will be displayed. positive integer.
cex
the expansion factor used to plot the edge points, the interpolated edge points and the interior points. positive numeric vector of size 3.

Value

A list of two elements :
  • [[edge]] : a data.frame containing the position ("i" "j") of the edge of the region, the edge number ("edge"), whether its user-specified point or interpolated point ("points") and whether it was removed for the filling precedure ("valid").
  • [[surface]] : a data.frame containing the position ("i" "j") of the points belonging to the region.

Details

FUNCTION: This function uses the locator function to obtain the coordinates of the cursor. It enable a point by point definition of a region where a linear interpolation is used between user-defined points to define the edge of the region. In the non sequential mode, the definition of the points stop if the number of points exceed n or using Echap. In the sequential mode, the definition of the points stop if the number of points exceed n or if the new point is close enough to the initial point.

After defining the edge, the region is filled.

Examples

Run this code
## Not run:  
# ## load a MRIaggr object
# data("MRIaggr.Pat1_red", package = "MRIaggr")
# num <- 3
# 
# ## display 1
# multiplot(MRIaggr.Pat1_red, param = "T2_FLAIR_t2",              
#              num = num, legend = FALSE, window = FALSE)
# 
# ## outline on display 1
# res <- outline(sequential=TRUE,min_dist=3)
# 
# ## display the results
# multiplot(MRIaggr.Pat1_red, param = "T2_FLAIR_t2",              
#              num = num, legend = FALSE,
#              index1 = data.frame(k = num, res$edge[,c("i","j")]),
#              index2 = data.frame(k = num, res$surface[,c("i","j")]),
#              window = FALSE)
# 
# carto <- selectContrast(MRIaggr.Pat1_red, param = c("MASK_T2_FLAIR_t2","index"),
#              num = num, coords = TRUE)
# carto <- merge(carto, cbind(res$surface, outline = TRUE), all = TRUE)
# carto[is.na(carto$outline),"outline"] <- FALSE
# head(carto)
# 
# ## display the results next to MASK_T2_FLAIR_t2
# multiplot(MRIaggr.Pat1_red, param = "T2_FLAIR_t2",              
#              num = num, legend = FALSE,
#              index1 = carto[carto$MASK_T2_FLAIR_t2,c("i","j","k")],
#              index2 = carto[carto$outline,c("i","j","k")],
#              window = FALSE)
# ## End(Not run)

Run the code above in your browser using DataLab