grow_black: Grow black regions in a binary mask

View source: R/grow_black.R

grow_blackR Documentation

Grow black regions in a binary mask

Description

Grow black pixels in a binary mask using a kernel of user-defined size. Useful to reduce errors associated with inter-class borders.

Usage

grow_black(bin, dist_to_black)

Arguments

bin

logical terra::SpatRaster with one layer. A binarized hemispherical image. See binarize_with_thr() for details.

dist_to_black

numeric vector of length one. Buffer distance (pixels) used to expand black regions.

Details

Expands the regions with value FALSE (typically rendered as black) in a binary image by applying a square-shaped buffer. Any white pixels (value TRUE) within a distance equal to or less than dist_to_black from a black pixel will be turned black.

Value

Logical terra::SpatRaster with the same dimensions as bin. Compared to the input bin, black regions (FALSE) have been expanded by the specified buffer distance.

Examples

## Not run: 
r <- read_caim()
bin <- binarize_with_thr(r$Blue, thr_isodata(r$Blue[]))
plot(bin)
bin <- grow_black(bin, 11)
plot(bin)

## End(Not run)

rcaiman documentation built on Sept. 9, 2025, 5:42 p.m.