Reconstruct a Model Cube from Cluster Representative Spectra
Source:R/reconstruct_cluster_cube.R
reconstruct_cluster_cube.RdThis function builds a model cube from a segmentation result by assigning one representative spectrum to every pixel in each cluster. It is useful for visualization, denoising, and downstream spectral analysis where a cluster-level spectral template is desired.
Arguments
- cluster_result
A list returned by a segmentation function.
- template
Representative spectrum to assign to each cluster.
"median"is robust,"mean"is the arithmetic cluster mean, and"weighted_mean"uses inverse-variance weighting.- var_cube
Optional variance cube. Required when
template = "weighted_mean".- variance_inflation
Multiplicative factor applied to propagated variances when
var_cubeis supplied.- preserve_mask
Logical; if
TRUE, channels that were non-finite in the original cube remain masked in the reconstructed cube.- fill_mode
Either
"na"or"zero"for unassigned pixels and, whenpreserve_mask = TRUE, for masked spectral channels.- return_residual
Logical; if
TRUE, also return the residual cube.