Apply Minimum Noise Fraction transformation to a SpatRaster
Source:R/hsi_apply_mnf.R
hsi_apply_mnf.RdApply Minimum Noise Fraction transformation to a SpatRaster
Arguments
- x
A
SpatRasterwith hyperspectral data.- fit
An object of class
mnfas returned byhsi_calc_mnf().- n
Positive integer. Number of signal-rich MNF components to retain. Inspect
fit$valuesto choose. DefaultNULL.- filename
Character. Output filename. Default
""keeps result in memory.- overwrite
Logical. Overwrite existing file. Default
FALSE.- ...
Additional arguments passed to
terra::writeRaster().
Value
A SpatRaster with n MNF component layers.
Details
MNF components are ordered by decreasing noise fraction: the first component
carries the most noise and the last carries the most signal. n selects the
signal-rich tail, so the output layer MNF_1 always corresponds to the most
signal-rich component regardless of the total number of components computed.
The internal index reversal is hidden from the user.
x is used only as a spatial template (extent, CRS, resolution). Its band
count is irrelevant — only cell count must match nrow(fit$x).
Separating hsi_calc_mnf() from hsi_apply_mnf() means the expensive
eigen decomposition runs once; hsi_apply_mnf() can be called repeatedly
with different values of n without recomputing the transform.
See also
Other HSI Transformations:
hsi_calc_difference(),
hsi_calc_mnf(),
hsi_calc_ndi(),
hsi_calc_raba(),
hsi_calc_rabd(),
hsi_calc_ratio(),
hsi_calc_rcv(),
hsi_calc_reflectance(),
hsi_calc_remp(),
hsi_calc_rmean(),
hsi_calc_rmedian(),
hsi_calc_rsd(),
hsi_calc_stretch(),
hsi_destripe(),
hsi_remove_continuum(),
hsi_smooth_median(),
hsi_smooth_savgol(),
hsi_tiled(),
hsi_write_scaled()
Examples
if (FALSE) { # \dontrun{
x <- terra::rast("REFLECTANCE_testdata.tif")
fit <- hsi_calc_mnf(x)
fit$values
x_mnf <- hsi_apply_mnf(x, fit = fit, n = 10L)
x_mnf <- hsi_apply_mnf(
x,
fit = fit,
n = 10L,
filename = "output_mnf.tif",
overwrite = TRUE
)
} # }