sor_filter: Statistical outlier removal (SOR) filter

View source: R/sor_filter.R

sor_filterR Documentation

Statistical outlier removal (SOR) filter

Description

Statistical outlier removal (SOR) filter

Usage

sor_filter(
  sky_points,
  r,
  z,
  a,
  k = 20,
  rmax = 20,
  thr = 2,
  cutoff_side = "both",
  use_window = TRUE
)

Arguments

sky_points

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

r

SpatRaster. The image from which the argument sky_points was obtained.

z

SpatRaster built with zenith_image().

a

SpatRaster built with azimuth_image().

k

Numeric vector of length one. Number of k-nearest neighbors.

rmax

Numeric vector of length one. The maximum radius for searching k-nearest neighbors (knn). Points are projected onto a unit-radius sphere, similar to the use of relative radius in image mapping. The spherical distance is then calculated and used to filter out points farther than rmax.The distance is expressed in degrees. If an insufficient number of neighbors are found within the search radius, the point is retained due to a lack of evidence for removal.

thr

Numeric vector of length one. See \insertCiteLeys2013;textualrcaiman.

cutoff_side

Character vector of length one. See \insertCiteLeys2013;textualrcaiman.

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 algorithm is based on the homonymous filter from the PCL library. Distances are computed on a spherical surface and expressed in degrees to avoid distortions due to projection. The number of neighbors used for evaluation is controlled by the k argument, while the rmax argument sets the maximum search radius for finding these neighbors. Points are projected onto a unit-radius sphere, similar to the use of relative radius in image mapping. The spherical distance is then calculated, and points farther than rmax are excluded from the neighbor set. If an insufficient number of neighbors are found within rmax, the point is retained due to a lack of evidence for removal. The decision criterion follows \insertCiteLeys2013;textualrcaiman:

M - thr \times MAD < x_i < M + thr \times MAD

where x_i is the value associated with a given sky point, M and MAD are the median and median absolute deviation, respectively, computed from the values associated with the neighbors of x_i, and thr is the user-defined threshold.

The argument cutoff_side controls which side of the inequality is tested—either one side or both.

Value

The argument sky_points with fewer rows due to outlier removal.

References

\insertAllCited

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(), vicinity_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)
plot(r)
points(sky_points$col, nrow(caim) - sky_points$row, col = 2, pch = 10)

sky_points <- sor_filter(sky_points, r, z, a, k = 10, rmax = 20, thr = 2,
                cutoff_side = "left")
points(sky_points$col, nrow(caim) - sky_points$row, col = 3, pch = 0)


## End(Not run)

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