vicinity_filter: Vicinity filter for planar and spherical coordinates

View source: R/vicinity_filter.R

vicinity_filterR Documentation

Vicinity filter for planar and spherical coordinates

Description

Filters out nearby points based on a minimum distance threshold in either planar (image space) or spherical (sky coordinates) systems.

Usage

vicinity_filter(
  sky_points,
  r = NULL,
  z = NULL,
  a = NULL,
  min_dist = 3,
  use_window = TRUE
)

Arguments

sky_points

The output of extract_sky_points() or an object of the same class and structure.

r

SpatRaster or NULL. Set the dimension that will be prioritized when deciding to retein a sky point.

z

SpatRaster built with zenith_image() or NULL.

a

SpatRaster built with azimuth_image() or NULL.

min_dist

Numeric vector of length one. Minimum allowed distance between points. In degrees for spherical space or pixels for planar space. What space is used depend on the arguments z and a, if both are provided, then the spherical space is used.

use_window

Logical vector of length one. If TRUE, a window of 3 \times 3 pixels will be used to extract the digital number from r.

Details

This function selects a subset of spatial points ensuring that no selected points are closer than min_dist. Optionally, it can prioritize retention of points with high values in a specific dimension such as image digital number.

Value

The argument sky_points with fewer rows due to the removal of points closer each other than min_dist.

See Also

Other Tool Functions: calc_oor_index(), calc_spherical_distance(), colorfulness(), correct_vignetting(), defuzzify(), display_caim(), extract_dn(), extract_feature(), extract_rel_radiance(), extract_sky_points(), extract_sun_coord(), find_sky_pixels(), masking(), optim_dist_to_black(), optim_normalize(), percentage_of_clipped_highlights(), read_bin(), read_caim(), read_caim_raw(), read_ootb_sky_model(), sor_filter(), write_bin(), write_caim(), write_ootb_sky_model()

Examples

## Not run: 
caim <- read_caim()
r <- caim$Blue
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- !is.na(z)
bin <- regional_thresholding(r, rings_segmentation(z, 30),
                             method = "thr_isodata")
bin <- bin & select_sky_vault_region(z, 0, 80)
g <- sky_grid_segmentation(z, a, 5, first_ring_different = TRUE)
sky_points <- extract_sky_points(r, bin, g,
                                 dist_to_black = 3)

sky_points_p <- vicinity_filter(sky_points, r, min_dist = 100)
plot(r)
points(sky_points$col, nrow(caim) - sky_points$row, col = 2, pch = 10)
points(sky_points_p$col, nrow(caim) - sky_points_p$row, col = 3, pch = 0)

sky_points_s <- vicinity_filter(sky_points, r, z, a, min_dist = 30)
plot(r)
points(sky_points$col, nrow(caim) - sky_points$row, col = 2, pch = 10)
points(sky_points_s$col, nrow(caim) - sky_points_s$row, col = 3, pch = 0)

## End(Not run)

GastonMauroDiaz/rcaiman documentation built on April 14, 2025, 9:39 a.m.