Select regions of interest in an image using different morphological operations
Arguments
- img
- threshold
A
numericto be passed tothresholdor avectorof values for each image inimg- shrink
A
numericto be passed toshrinkor avectorof values for each image inimg- grow
A
numericto be passed togrowor avectorof values for each image inimg- fill
A
numericto be passed tofillor avectorof values for each image inimg- clean
A
numericto be passed tocleanor avectorof values for each image inimg- tolerance
A
numericto be passed tolabelor avectorof values for each image inimg- n
A
numericof the number of regions of interest or avectorof values for each image inimg
Value
A cimg. The original input img with an
additional attribute label. label is a vector of
integers. The labels for the selected regions of interests starts
from 1 and 0 is ignored. When img is a list, a list is
returned.
Details
The function applies several imager morphological
manipulations to select the regions of interest. These include
threshold which sets all values below certain cut to
0; shrink/grow for pixel set
dilation and erosion; fill/clean
for removing isolated regions and holes. When n is provided, the
individual regions (connected components) are selected where tolerance
is used to determine if two pixels belong to the same region.
Examples
# load images
fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr')
img <- image_load(fl)
# choose ROI
newimg <- roi_select(img, threshold = 90)
# check the ROI labels
unique(attr(newimg, 'label'))
#> [1] 0 1
