| collapse_spec {OpenSpecy} | R Documentation |
Define features
Description
Functions for analyzing features, like particles, fragments, or fibers, in
spectral map oriented OpenSpecy object.
Usage
collapse_spec(x, ...)
## Default S3 method:
collapse_spec(x, ...)
## S3 method for class 'OpenSpecy'
collapse_spec(x, ...)
def_features(x, ...)
## Default S3 method:
def_features(x, ...)
## S3 method for class 'OpenSpecy'
def_features(
x,
features,
shape_kernel = c(3, 3),
shape_type = "box",
close = F,
close_kernel = c(4, 4),
close_type = "box",
img = NULL,
bottom_left = NULL,
top_right = NULL,
...
)
Arguments
x |
an |
features |
a logical vector or character vector describing which of the
spectra are of features ( |
shape_kernel |
the width and height of the area in pixels to search for connecting features, c(3,3) is typically used but larger numbers will smooth connections between particles more. |
shape_type |
character, options are for the shape used to find connections c("box", "disc", "diamond") |
close |
logical, whether a closing should be performed using the shape kernel before estimating components. |
close_kernel |
width and height of the area to close if using the close option. |
close_type |
character, options are for the shape used to find connections c("box", "disc", "diamond") |
img |
a file location where a visual image is that corresponds to the spectral image. |
bottom_left |
a two value vector specifying the x,y location in image pixels where the bottom left of the spectral map begins. y values are from the top down while x values are left to right. |
top_right |
a two value vector specifying the x,y location in the visual image pixels where the top right of the spectral map extent is. y values are from the top down while x values are left to right. |
... |
additional arguments passed to subfunctions. |
Details
def_features() accepts an OpenSpecy object and a logical or
character vector describing which pixels correspond to particles.
collapse_spec() takes an OpenSpecy object with particle-specific
metadata (from def_features()) and collapses the spectra to median
intensities for each unique particle.
It also updates the metadata with centroid coordinates, while preserving the
feature information on area and Feret max.
Value
An OpenSpecy object appended with metadata about the features or
collapsed for the features. All units are in pixels. Metadata described below.
xx coordinate of the pixel or centroid if collapsed
yy coordinate of the pixel or centroid if collapsed
feature_idunique identifier of each feature
areaarea in pixels of the feature
perimeterperimeter of the convex hull of the feature
feret_minferet_max divided by the area
feret_maxlargest dimension of the convex hull of the feature
convex_hull_areaarea of the convex hull
centroid_xmean x coordinate of the feature
centroid_ymean y coordinate of the feature
first_xfirst x coordinate of the feature
first_yfirst y coordinate of the feature
rand_xrandom x coordinate from the feature
rand_yrandom y coordinate from the feature
rif using visual imagery overlay, the red band value at that location
gif using visual imagery overlay, the green band value at that location
bif using visual imagery overlay, the blue band value at that location
Author(s)
Win Cowger, Zacharias Steinmetz
Examples
tiny_map <- read_extdata("CA_tiny_map.zip") |> read_any()
identified_map <- def_features(tiny_map, tiny_map$metadata$x == 0)
collapse_spec(identified_map)