profoundSegimGroup: Create Segmentation Groups

View source: R/profoundSegim.R

profoundSegimGroupR Documentation

Create Segmentation Groups

Description

Given an input segmentation map, returns a map of groups of touching segments as well as the IDs of segments within each group.

Usage

profoundSegimGroup(segim = NULL)

Arguments

segim

Integer matrix; required, the segmentation map.

Details

profoundSegimGroup uses the label function from imager, so to use this function you will need to have imager installed. Since this can be a bit cumbersome on some platforms (given its dependencies) this is only listed as a suggested package.

Value

A list containting the following structures:

groupim

An map of the unique groups identified in the input segim, where the groupID is the same as the lowest valued segID in the group.

groupsegID

A data.frame of lists giving the segIDs of segments in each group.

The data.frame returned by groupsegID is a slightly unusal structure to see in R, but it allows for a compact manner of storing uneven vectors of grouped segments. E.g. you might have a massive group containing 30 other segments and many groups containing a single segment. Padding a normal matrix out to accommodate the larger figure would be quite inefficient. It contains the following:

groupID

Group ID, which can be matched against values in groupim

segID

An embedded list of segmentation IDs for segments in the group. I.e. each list element of segID is a vector (see Examples for clarity).

Ngroup

The total number of segments that are in the group.

Npix

The total number of pixels that are in the group.

Author(s)

Aaron Robotham

See Also

profoundSegimNear, ~~~

Examples

## Not run: 
image = Rfits_read_image(system.file("extdata", 'VIKING/mystery_VIKING_Z.fits',
  package="ProFound"))
profound=profoundProFound(image, skycut=1.5, magzero=30, verbose=TRUE)

#Look for nearby (in this case touching) neighbours

group=profoundSegimGroup(profound$segim)

#Look at the first few rows (groups 1:5):

group$groupsegID[1:5,]

#To access the embedded vectors you have to use unlist:

unlist(group$groupsegID[1,2])

#We can check to see which segments are in group number 1:

profoundSegimPlot(image$imDat, profound$segim)
magimage(group$groupim==1, col=c(NA,'red'), add=TRUE)

## End(Not run)

asgr/ProFound documentation built on Feb. 10, 2024, 9:04 p.m.