View source: R/paint_with_mask.R
paint_with_mask | R Documentation |
Paint image pixels inside or outside a logical mask with a solid color.
paint_with_mask(r, m, color = "red", where = "outside")
r |
terra::SpatRaster. The image. Values should be normalized,
see |
m |
logical terra::SpatRaster with one layer. A binary mask with
|
color |
character vector of length one or numeric vector of length
three. Fill color. If character, it is converted to RGB automatically. If
numeric, values must be in range |
where |
character vector of length one Region to paint relative to |
numeric terra::SpatRaster with three layers and the geometry
of r
. Equal to r
, but with pixels in the selected region painted with
color
. Single-layer inputs are replicated to allow color painting.
## Not run:
r <- read_caim()
z <- zenith_image(ncol(r), lens())
a <- azimuth_image(z)
m <- select_sky_region(z, 20, 70) & select_sky_region(a, 90, 180)
masked_caim <- paint_with_mask(normalize_minmax(r), m)
plotRGB(masked_caim * 255)
masked_bin <- paint_with_mask(binarize_with_thr(r$Blue, 125), m)
plotRGB(masked_bin * 255)
r <- normalize_minmax(r)
paint_with_mask(r, m, color = c(0.2, 0.2, 0.2)) # vector
paint_with_mask(r, m, color = "blue") # name
paint_with_mask(r, m, color = "#00FF00") # hexadecimal
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.