Learn R Programming

rcaiman (version 2.0.1)

rem_isolated_black_pixels: Remove isolated black pixels

Description

Replace single black pixels (FALSE) that are fully surrounded by white pixels (TRUE) with white. Uses 8-connectivity.

Usage

rem_isolated_black_pixels(bin)

Value

Logical terra::SpatRaster of one layer.

Arguments

bin

logical terra::SpatRaster with a single layer.

Examples

Run this code
if (FALSE) {
caim <- read_caim()
r <- caim$Blue
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)

path <- system.file("external/example.txt", package = "rcaiman")
sky <- read_sky_cie(gsub(".txt", "", path), caim$Blue, z, a)
plot(sky$rr_raster)
sky <- sky$rr_raster * sky$model$rr$zenith_dn

bin <- binarize_with_thr(r / sky, 0.9)
plot(bin)
bin2 <- rem_isolated_black_pixels(bin)
plot(bin2)
}

Run the code above in your browser using DataLab