Learn R Programming

rcaiman (version 2.0.1)

grow_black: 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)

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.

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.

Examples

Run this code
if (FALSE) {
r <- read_caim()
bin <- binarize_with_thr(r$Blue, thr_isodata(r$Blue[]))
plot(bin)
bin <- grow_black(bin, 11)
plot(bin)
}

Run the code above in your browser using DataLab