| ssim_raster | R Documentation |
This function calculates the Structural Similarity Index Measure (SSIM) between two raster images. It can return either global SSIM summaries or local SSIM raster layers. Optional permutation-based statistical inference can also be performed for global or local SSIM values.
ssim_raster(
map1,
map2,
global = TRUE,
w = 1,
transform = c("normal_score", "percentile", "none", "minmax"),
k1 = NULL,
k2 = NULL,
do_test = FALSE,
local_test = FALSE,
R = 1000,
fdr = TRUE,
alpha = 0.05,
seed = NULL
)
map1 |
A single-layer |
map2 |
A single-layer |
global |
Logical. If |
w |
Integer. Radius of the local moving window used to calculate local
SSIM components. For example, |
transform |
Character. Transformation applied to both raster maps before
SSIM calculation. Options are |
k1 |
Numeric. Constant used to stabilize the luminance component of SSIM.
If |
k2 |
Numeric. Constant used to stabilize the contrast and structure
components of SSIM. If |
do_test |
Logical. If |
local_test |
Logical. If |
R |
Integer. Number of permutations used for statistical inference.
Default is |
fdr |
Logical. If |
alpha |
Numeric. Significance level used to determine significant SSIM
values. Default is |
seed |
Optional integer. Random seed used for permutation testing.
Default is |
The SSIM index is calculated as the product of three components:
similarity in mean intensity, similarity in variance, and similarity in
spatial pattern. These components are returned as SIM, SIV, and
SIP, respectively.
The local SSIM calculation uses a square moving window with size
(2 * w + 1) x (2 * w + 1).
When do_test = TRUE, permutation testing is performed by randomly
permuting the values of map2 over the overlapping non-NA cells
and recalculating SSIM values.
If global = TRUE and do_test = FALSE, a list containing a summary
table of global SSIM, SIM, SIV, and SIP values is returned.
If global = TRUE and do_test = TRUE, a list containing the
summary table, permutation null distributions, p-values, and optionally
q-values is returned.
If global = FALSE and do_test = FALSE, a
terra::SpatRaster object with four layers is returned:
SSIM, SIM, SIV, and SIP.
If global = FALSE, do_test = TRUE, and
local_test = TRUE, a terra::SpatRaster object is returned with
local SSIM component layers, p-value layers, optionally q-value layers, and
significance layers.
## Not run:
library(terra)
# Global SSIM summary
g1 <- ssim_raster(
map1,
map2,
global = TRUE,
w = 1
)
# Local SSIM raster layers
l1 <- ssim_raster(
map1,
map2,
global = FALSE,
w = 1
)
# Local SSIM with permutation test
l2 <- ssim_raster(
map1,
map2,
global = FALSE,
w = 1,
do_test = TRUE,
local_test = TRUE,
R = 999
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.